Learn R Programming

simsem (version 0.4-6)

estmodel: Shortcut for data analysis template for simulation.

Description

Creates a data analysis template (lavaan parameter table) for simulations with structural equation models based on Y-side LISREL design matrices. Each corresponds to a LISREL matrix, but must be a matrix or a vector. In addition to the usual Y-side matrices in LISREL, both PS and TE can be specified using correlations (RPS, RTE) and scaled by a vector of residual variances (VTE, VPS) or total variances (VY, VE). Multiple groups are supported by passing lists of matrices or vectors to arguments, or by specifying the number of groups.

Usage

estmodel(LY = NULL, PS = NULL, RPS = NULL, TE = NULL, RTE = NULL, BE = NULL, 
	VTE = NULL, VY = NULL, VPS = NULL, VE=NULL, TY = NULL, AL = NULL, 
	MY = NULL, ME = NULL, modelType, indLab = NULL, facLab = NULL, 
	groupLab = "group", ngroups = 1, con = NULL)
estmodel.cfa(LY = NULL,PS = NULL,RPS = NULL, TE = NULL,RTE = NULL, VTE = NULL, 
	VY = NULL, VPS = NULL, VE = NULL, TY = NULL, AL = NULL, MY = NULL, ME = NULL, 
	indLab = NULL, facLab = NULL, groupLab = "group", ngroups = 1, con = NULL)
estmodel.path(PS = NULL, RPS = NULL, BE = NULL, VPS = NULL, VE = NULL, AL = NULL, 
	ME = NULL, indLab = NULL, facLab = NULL, groupLab = "group", ngroups = 1,
	con = NULL)
estmodel.sem(LY = NULL,PS = NULL,RPS = NULL, TE = NULL,RTE = NULL, BE = NULL, 
	VTE = NULL, VY = NULL, VPS = NULL, VE = NULL, TY = NULL, AL = NULL, MY = NULL, 
	ME = NULL, indLab = NULL, facLab = NULL, groupLab = "group", ngroups = 1,
	con = NULL)

Arguments

LY
Factor loading matrix from endogenous factors to Y indicators (need to be a matrix or a list of matrices).
PS
Residual covariance matrix among endogenous factors (need to be a symmetric matrix or a list of symmetric matrices).
RPS
Residual correlation matrix among endogenous factors (need to be a symmetric matrix or a list of symmetric matrices).
TE
Measurement error covariance matrix among Y indicators (need to be a symmetric matrix or a list of symmetric matrices).
RTE
Measurement error correlation matrix among Y indicators (need to be a symmetric matrix or a list of symmetric matrices).
BE
Regression coefficient matrix among endogenous factors (need to be a matrix or a list of matrices).
VTE
Measurement error variance of indicators (need to be a vector or a list of vectors).
VY
Total variance of indicators (need to be a vector or a list of vectors). NOTE: Either measurement error variance or indicator variance is specified. Both cannot be simultaneously specified.
VPS
Residual variance of factors (need to be a vector or a list of vectors).
VE
Total variance of of factors (need to be a vector or a list of vectors). NOTE: Either residual variance of factors or total variance of factors is specified. Both cannot be simulatneously specified.
TY
Measurement intercepts of Y indicators. (need to be a vector or a list of vectors).
AL
Endogenous factor intercept (need to be a vector or a list of vectors).
MY
Overall Y indicator means. (need to be a vector or a list of vectors). NOTE: Either measurement intercept of indicator mean can be specified. Both cannot be specified simultaneously.
ME
Total mean of endogenous factors (need to be a vector or a list of vectors). NOTE: Either endogenous factor intercept or total mean of endogenous factor is specified. Both cannot be simultaneously specified.
modelType
"CFA", "Sem", or "Path". This is specified to ensure that the analysis and data generation template created based on specified matrices in model correspond to what the user intends.
indLab
Character vector of indicator labels. If left blank, automatic labels will be generated as y1, y2, ... yy.
facLab
Character vector of factor labels. If left blank, automatic labels will be generated as f1, f2, ... ff
groupLab
Character of group-variable label (not the names of each group). If left blank, automatic labels will be generated as group
ngroups
Integer. Number of groups for data generation, defaults to 1. If larger than one, all specified matrices will be repeated for each additional group. If any matrix argument is a list, the length of this list will be the number of groups and ngroups is igno
con
Additional parameters (phantom variables), equality constraints, and inequality constraints that users wish to specify in the model. The additional parameters are specified in lavaan syntax. The allowed operator are ":=" (is defined as), "==" (is equal to

Value

  • SimSem object that contains the data generation template (@dgen) and analysis template (@pt).

Details

This function contains default settings: For modelType="CFA", LY is required. As the default, the on-diagonal elements of PS are fixed as 1 and the off-diagonal elements of PS are freely estimated. The off-diagonal elements of TE are freely estimated and the off-diagonal elements of TE are fixed to 0. The AL elements are fixed to 0. The TY elements are freely estimated. For modelType="Path", BE is required. As the default, the on-diagonal elements of PS are freely estimated, the off-diagonal elements between exogenous variables (covariance between exogenous variables) are freely estimated, and the other off-diagonal elements are fixed to 0. The AL elements are freely estimated. For modelType="SEM", LY and BE are required. As the default, the on-diagonal elements of PS are fixed to 1, the off-diagonal elements between exogenous factors (covariance between exogenous factors) are freely estimated, and the other off-diagonal elements are fixed to 0. The off-diagonal elements of TE are freely estimated and the off-diagonal elements of TE are fixed to 0. The AL elements are fixed to 0. The TY elements are freely estimated. The estmodel.cfa, estmodel.path, and estmodel.sem are the shortcuts for the estmodel function when modelType are "CFA", "Path", and "SEM", respectively.

See Also

  • modelTo build data generation and data analysis template for simulation.
  • simFor simulations using theSimSemtemplate.
  • generateTo generate data using theSimSemtemplate.
  • analyzeTo analyze real or generated data using theSimSemtemplate.
  • drawTo draw parameters using theSimSemtemplate.

Examples

Run this code
loading <- matrix(0, 12, 4)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
loading[10:12, 4] <- NA

CFA.Model <- estmodel(LY = loading, modelType = "CFA")

path <- matrix(0, 4, 4)
path[3, 1:2] <- NA
path[4, 3] <- NA
Path.Model <- estmodel(BE = path, modelType = "Path")

SEM.Model <- estmodel(BE = path, LY = loading, modelType="SEM")

# Shortcut
CFA.Model <- estmodel.cfa(LY = loading)
Path.Model <- estmodel.path(BE = path)
SEM.Model <- estmodel.sem(BE = path, LY = loading)

Run the code above in your browser using DataLab