simsem (version 0.2-8)

simSetSEM: Create a set of matrices of parameter and parameter values to generate and analyze data that belongs to SEM model

Description

This function will create set of matrices of free parameters and parameter values that belongs to full SEM model. The requirement is to specify factor residual correlation or covariance matrix, regression coefficient matrix, factor loading matrix, and measurement error correlation or covariance matrix.

Usage

simSetSEM(..., exo = FALSE)

Arguments

...
Each element of model specification, as described in Details
exo
specify TRUE if users wish to specify both exogenous and endogenous indicators.

Value

  • SimSet object that represents the SEM object. This will be used for specifying data or analysis models later.

Details

The matrices and vectors in the endogenous side are
  • LYfor factor loading matrix from endogenous factors to Y indicators (need to beSimMatrixobject).
  • TEfor measurement error covariance matrix among Y indicators (need to beSymMatrixobject).
  • RTEfor measurement error correlation matrix among Y indicators (need to beSymMatrixobject).
  • BEfor regression coefficient matrix among endogenous factors (need to beSimMatrixobject).
  • PSfor residual covariance matrix among endogenous factors (need to beSymMatrixobject).
  • RPSfor residual correlation matrix among endogenous factors (need to beSymMatrixobject).
  • VTEfor measurement error variance of Y indicators (need to beSimVectorobject).
  • VYfor total variance of Y indicators (need to beSimVectorobject). NOTE: Either measurement error variance or indicator variance is specified. Both cannot be simultaneously specified.
  • TYfor measurement intercepts of Y indicators. (need to beSimVectorobject).
  • MYfor overall Y indicator means. (need to beSimVectorobject). NOTE: Either measurement intercept of indicator mean can be specified. Both cannot be specified simultaneously.
  • VPSfor residual variance of endogenous factors (need to beSimVectorobject).
  • VEfor total endogenous factor variance (need to beSimVectorobject). NOTE: Either total endogenous factor variance or residual endogenous factor variance is specified. Both cannot be simultaneously specified.
  • ALfor endogenous factor intercept (need to beSimVectorobject).
  • MEfor total mean of endogenous factors (need to beSimVectorobject). NOTE: Either endogenous factor intercept or total mean of endogenous factor is specified. Both cannot be simultaneously specified.
There are four required matrices for the specification in the endogenous side only: LY, RTE (or TE), BE, and RPS (or PS). If users need to specify exogenous variable too ("exo=TRUE"), these matrices and vectors are available:
  • LXfor factor loading matrix from exogenous factors to X indicators (need to beSimMatrixobject).
  • TDfor measurement error covariance matrix among X indicators (need to beSymMatrixobject).
  • RTDfor measurement error correlation matrix among X indicators (need to beSymMatrixobject).
  • GAfor regression coefficient matrix among exogenous factors (need to beSimMatrixobject).
  • PHfor residual covariance matrix among exogenous factors (need to beSymMatrixobject).
  • RPHfor residual correlation matrix among exogenous factors (need to beSymMatrixobject).
  • VTDfor measurement error variance of X indicators (need to beSimVectorobject).
  • VXfor total variance of X indicators (need to beSimVectorobject). NOTE: Either measurement error variance or indicator variance is specified. Both cannot be simultaneously specified.
  • TXfor measurement intercepts of Y indicators. (need to beSimVectorobject).
  • MXfor overall Y indicator means. (need to beSimVectorobject). NOTE: Either measurement intercept of indicator mean can be specified. Both cannot be specified simultaneously.
  • VPHorVKfor total exogenous factor variance (need to beSimVectorobject).
  • KAorMKfor total mean of exogenous factors (need to beSimVectorobject).
  • THfor measurement error covariance between X measurement error and Y measurement error.
  • RTHfor measurement error correlation between X measurement error and Y measurement error.
There are eight required matrices for the specification in both exogenous and endogenous sides: LY, RTE (or TE), BE, RPS (or PS), LX, RTD (or TD), GA, and RPH (or PH). If users specify the correlation/variance format (instead of the covariance format), the default specifications are
  1. All indicator variances are equal to 1. Measurement error variances are automatically implied from total indicator variances.
  2. All measurement error variances are free parameters.
  3. All indicator means are equal to 0. Indicator intercepts are automatically implied from indicator means.
  4. All indicator intercepts are free parameters.
  5. All factor variances are equal to 1.
  6. All factor variances are fixed.
  7. All factor means are equal to 0.
  8. All factor means are fixed.

See Also

  • See classSimSetfor simResult details.
  • SeeSimMatrix,SymMatrix, orSimVectorfor input details.
  • UsesimSetCFAto specify CFA model and usesimSetPathto specify path analysis model.

Examples

Run this code
u35 <- simUnif(0.3, 0.5)
u68 <- simUnif(0.6, 0.8)
n65 <- simNorm(0.6, 0.05)
loading <- matrix(0, 8, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:8, 3] <- NA
loading.start <- matrix("", 8, 3)
loading.start[1:3, 1] <- 0.7
loading.start[4:6, 2] <- 0.7
loading.start[7:8, 3] <- "u68"
LY <- simMatrix(loading, loading.start)

RTE <- symMatrix(diag(8))

factor.cor <- diag(3)
factor.cor[1, 2] <- factor.cor[2, 1] <- NA
RPS <- symMatrix(factor.cor, 0.5)

path <- matrix(0, 3, 3)
path[3, 1:2] <- NA
path.start <- matrix(0, 3, 3)
path.start[3, 1] <- "n65"
path.start[3, 2] <- "u35"
BE <- simMatrix(path, path.start)

SEM.model <- simSetSEM(BE=BE, LY=LY, RPS=RPS, RTE=RTE)

loading.X <- matrix(0, 6, 2)
loading.X[1:3, 1] <- NA
loading.X[4:6, 2] <- NA
LX <- simMatrix(loading.X, 0.7)

loading.Y <- matrix(NA, 2, 1)
LY <- simMatrix(loading.Y, "u68")

RTD <- symMatrix(diag(6))

RTE <- symMatrix(diag(2))

factor.K.cor <- matrix(NA, 2, 2)
diag(factor.K.cor) <- 1
RPH <- symMatrix(factor.K.cor, 0.5)

RPS <- symMatrix(as.matrix(1))

path.GA <- matrix(NA, 1, 2)
path.GA.start <- matrix(c("n65", "u35"), ncol=2)
GA <- simMatrix(path.GA, path.GA.start)

BE <- simMatrix(as.matrix(0))

SEM.Exo.model <- simSetSEM(GA=GA, BE=BE, LX=LX, LY=LY, RPH=RPH, RPS=RPS, RTD=RTD, RTE=RTE, exo=TRUE)

Run the code above in your browser using DataCamp Workspace