Skip to contents

get_scores() takes n_items amount of items that load the most (either by loading cutoff or number) on a component, and then computes their average.

Usage

get_scores(x, n_items = NULL)

Arguments

x

An object returned by principal_components().

n_items

Number of required (i.e. non-missing) items to build the sum score. If NULL, the value is chosen to match half of the number of columns in a data frame.

Value

A data frame with subscales, which are average sum scores for all items from each component.

Details

get_scores() takes the results from principal_components() and extracts the variables for each component found by the PCA. Then, for each of these "subscales", row means are calculated (which equals adding up the single items and dividing by the number of items). This results in a sum score for each component from the PCA, which is on the same scale as the original, single items that were used to compute the PCA.

Examples

if (require("psych")) {
  pca <- principal_components(mtcars[, 1:7], n = 2, rotation = "varimax")

  # PCA extracted two components
  pca

  # assignment of items to each component
  closest_component(pca)

  # now we want to have sum scores for each component
  get_scores(pca)

  # compare to manually computed sum score for 2nd component, which
  # consists of items "hp" and "qsec"
  (mtcars$hp + mtcars$qsec) / 2
}
#>  [1]  63.230  63.510  55.805  64.720  96.010  62.610 130.420  41.000  58.950
#> [10]  70.650  70.950  98.700  98.800  99.000 111.490 116.410 123.710  42.735
#> [19]  35.260  42.450  58.505  83.435  83.650 130.205  96.025  42.450  53.850
#> [28]  64.950 139.250  95.250 174.800  63.800