cpa_scores {configural}R Documentation

Compute CPA level and pattern scores for a set of data

Description

Compute CPA level and pattern scores for a set of data

Usage

cpa_scores(
  cpa_mod,
  newdata = NULL,
  augment = TRUE,
  cpa_names = c("cpa_lev", "cpa_pat"),
  scale = FALSE,
  scale_center = TRUE,
  scale_scale = TRUE
)

Arguments

cpa_mod

A model returned from cpa_mat() (a model of class "cpa")

newdata

A data frame or matrix containing columns with the same names as the predictors in cpa_mod.

augment

Should be CPA score columns be added to newdata (TRUE, default) or returned alone (FALSE)?

cpa_names

Character vector of length 2 giving the variable names to assign to the CPA score columns.

scale

Logical. Should the variables in newdata be scaled (standardized)?

scale_center

If scale is TRUE, passed to the center argument in base::scale(). Can be TRUE (center columns of newdata around the column means), FALSE (don't center), or a numeric vector of length equal to the number of predictors in cpa_mod containing the values to center around.

scale_scale

If scale is TRUE, passed to the scale argument in base::scale(). Can be TRUE (scale/standardize columns of newdata using the column standard deviations or root mean squares), FALSE (don't scale), or a numeric vector of length equal to the number of predictors in cpa_mod containing the values to scale by. See base::scale() for details.

Value

A data frame containing the CPA score variables.

Examples

sevar <- cor_covariance_meta(mindfulness$r, mindfulness$n, mindfulness$sevar_r, mindfulness$source)
cpa_mod <- cpa_mat(mindfulness ~ ES + A + C + Ex + O,
                   cov_mat = mindfulness$r,
                   n = NULL,
                   se_var_mat = sevar,
                   adjust = "pop")

newdata <- data.frame(ES = c(4.2, 3.2, 3.4, 4.2, 3.8, 4.0, 5.6, 2.8, 3.4, 2.8),
                      A  = c(4.0, 4.2, 3.8, 4.6, 4.0, 4.6, 4.6, 2.6, 3.6, 5.4),
                      C  = c(2.8, 4.0, 4.0, 3.0, 4.4, 5.6, 4.4, 3.4, 4.0, 5.6),
                      Ex = c(3.8, 5.0, 4.2, 3.6, 4.8, 5.6, 4.2, 2.4, 3.4, 4.8),
                      O  = c(3.0, 4.0, 4.8, 3.2, 3.6, 5.0, 5.4, 4.2, 5.0, 5.2)
                      )

newdata_cpa <- cpa_scores(cpa_mod, newdata, augment = FALSE)
newdata_augment <- cpa_scores(cpa_mod, newdata, augment = TRUE)

[Package configural version 0.1.5 Index]