Learn R Programming

simsem (version 0.2-8)

simModel: Create a model object

Description

This function will take model specification from SimSet that contains free parameters, starting values, and fixed values. It will transform the code to a specified SEM package and ready to analyze data.

Usage

simModel(object, ...)

Arguments

object
SimSet that provides model specification
...
Other values that will be explained specifically for each class

Value

  • SimModel that will be used for data analysis

Details in ...

  • start:SimRSet.c that saves all starting values in the model.
  • equalCon:SimEqualCon.c that save constraints specified by users. The default is no constraint.
  • package:Desired analysis package
  • estimator:The default isMLestimator. Other alternatives areGLS,WLS,MLM,MLF, andMLR. Check the sem function help file in thelavaanpackage for further details
  • auxiliary:The names or the index of the auxiliary variables in the data
  • indLab:The names of the variable in the model. The exogenous indicators should be listed first (from x1) and then endogenous indicators should be listed next (from y1).
  • factorLab:The names of the factors in the model. The exogenous factors should be listed first (from k1) and then endogenous factors should be listed next (from y1).

See Also

  • SimModelfor the simResult
  • SimSetfor the target object containing model specification

Examples

Run this code
loading <- matrix(0, 6, 2)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loadingValues <- matrix(0, 6, 2)
loadingValues[1:3, 1] <- 0.7
loadingValues[4:6, 2] <- 0.7
LX <- simMatrix(loading, loadingValues)
latent.cor <- matrix(NA, 2, 2)
diag(latent.cor) <- 1
RPH <- symMatrix(latent.cor, 0.5)
error.cor <- matrix(0, 6, 6)
diag(error.cor) <- 1
RTD <- symMatrix(error.cor)
CFA.Model <- simSetCFA(LX = LX, RPH = RPH, RTD = RTD)
SimModel <- simModel(CFA.Model)

library(lavaan)
loading <- matrix(0, 9, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
HS.Model <- simParamCFA(LX = loading)
SimModel <- simModel(HS.Model, indLab=paste("x", 1:9, sep=""))
out <- run(SimModel, HolzingerSwineford1939)
summary(out)

Run the code above in your browser using DataLab