make_mplus_gpcm_vmmc_syntax: Preparing Mplus code to estimate RS models

View source: R/resp_styles_to_mplus.R

make_mplus_gpcm_vmmc_syntaxR Documentation

Preparing Mplus code to estimate RS models

Description

Prepares components of Mplus model description syntax.

Usage

make_mplus_gpcm_vmmc_syntax(
  items,
  scoringMatrix,
  observedExogenous = vector(mode = "character", length = 0L),
  observedDependent = vector(mode = "character", length = 0L),
  fixSlopes = vector(mode = "character", length = 0L),
  reverseCoded = vector(mode = "list", length = 0L),
  orthogonal = vector(mode = "character", length = 0L),
  weight = NA_character_,
  itemCategories = rep(list(rownames(scoringMatrix)), length(items)),
  trySimpleGPCM = TRUE
)

Arguments

items

a character vector of item names or a list describing items matching to latent traits in a between-item multidimensional model; in the latter case list elements must be named after column names of the scoringMatrix with each element being a list describing different latent traits that should be scored using a given column of the scoringMatrix; names of these second-level elements specify names of latent traits and elements themselves are character vectors of item names that are assigned to (loaded) a given latent trait

scoringMatrix

a matrix describing how responses (described in rownames of the matrix) map on scores of latent traits (described in columns of the matrix)

observedExogenous

either:

  • a character vector with names of observed exogenous predictors that should be used to predict latent variables in the model

  • a matrix with latent traits in columns and observed exogenous predictors in rows specifying which of the exogenous predictors should be used to predict which latent traits (matrix should contain only 0 and 1 or TRUE and FALSE)

observedDependent

either:

  • a character vector with names of observed dependent variables that should be predicted using latent variables in the model

  • a matrix with latent traits in columns and observed dependent variables in rows specifying which of the dependent variables should be predicted by which latent traits (matrix should contain only 0 and 1 or TRUE and FALSE)

fixSlopes

optionally a character vector of latent trait names for which item slopes parameters should be fixed across items (these names need to occur in column names of scoringMatrix)

reverseCoded

optionally a named list of character vectors with names of list elements specifying latent trait names and elements giving names of items that are reverse coded with respect to this latent trait; please note, that these don't need to be given if slopes of the no-RS trait(s) are not fixed across items

orthogonal

optionally a character vector of latent trait names indicating which latent traits should be specified as orthogonal to each other (all the mentioned latent traits will be specified as orthogonal to each other and all the other latent traits)

weight

optionally a string with a name of the variable storing weights

itemCategories

a list of values that a given item takes in the data

trySimpleGPCM

a logical value indicating whether to try to use a simple Mplus GPCM specification instead of the NRM when scoringMatrix has only one column

Details

Models are identified by fixing variances of the the latent variables that are not mentioned in fixSlopes to 1 and by fixing slope parameters to 1 (or -1 in a case of reverse coded items) and freeing latent trait variances that are mentioned in fixSlopes.

Please note that Mplus assumes that the last category is always scored 0, so if scoringMatrix contains some non-zero elements in its last row function will automatically adjust the coding scheme for latent traits (columns of the scoringMatrix) where last cell is non-zero by subtracting value in this cell from the whole column. Typically this will introduce negative scores to this column, but this is something Mplus can carry and it doesn't affect estimates of slope parameters. However, this will make estimated intercept parameters incomparable with the specification using the original scoring scheme. Also, this will make slope parameters for a given latent trait negative (while preserving the origin - for the purpose of interpretation - of the latent trait itself).

Value

A list of strings with elements named VARIABLE, MODEL and MODELCONSTRAINT (the last one can be NULL)


tzoltak/rstyles documentation built on Dec. 4, 2024, 5:16 p.m.