make.latent {quest}R Documentation

Make Model Syntax for a Latent Factor in Lavaan

Description

make.latent makes the model syntax for a latent factor in lavaan. The return object can be used as apart of the model syntax for calls to lavaan, sem, cfa, etc.

Usage

make.latent(
  x,
  nm.latent = "latent",
  error.var = FALSE,
  nm.par = FALSE,
  suffix.load = "_l",
  suffix.error = "_e"
)

Arguments

x

character vector specifying the colnames in your data that correspond to the variables indicating the latent factor (e.g., questionnaire items).

nm.latent

character vector of length 1 specifying what the latent factor should be labeled as in the return object.

error.var

logical vector of length 1 specifying whether the model syntax for the error variances should be included in the return object.

nm.par

logical vector of length 1 specifying whether the model syntax should include names for the factor loading (and error variance) parameters.

suffix.load

character vector of length 1 specifying what string should be appended to the end of the elements of x when creating names for the factor loading parameters. Only used if nm.par is TRUE.

suffix.error

character vector of length 1 specifying what string should be appended to the end of the elements of x when creating names for the error variance parameters. Only used if nm.par is TRUE.

Value

character vector of length 1 providing the model syntax. The regular expression "\n" is used to delineate new lines within the model syntax.

Examples


make.latent(x = names(psych::bfi)[1:5], error.var = FALSE, nm.par = FALSE)
make.latent(x = names(psych::bfi)[1:5], error.var = FALSE, nm.par = TRUE)
make.latent(x = names(psych::bfi)[1:5], error.var = TRUE, nm.par = FALSE)
make.latent(x = names(psych::bfi)[1:5], error.var = TRUE, nm.par = TRUE)


[Package quest version 0.2.0 Index]