Learn R Programming

simsem (version 0.2-8)

simData: Create a Data object

Description

This function will be used to create data specification and ready for data simulation.

Usage

simData(param, ...)

Arguments

param
Model specification matrices that are created by simSetCFA, simSetPath, or simSetSEM or the analysis
...
Other values that will be explained specifically for each class

Value

  • SimData object that save data model specification.

Details in ...

  • n:Desired sample size
  • misspec:Modelmisspecificationmatrices that are created bysimMisspecCFA,simMisspecPath, orsimMisspecSEM.
  • equalCon:Equality constraints that are created bysimEqualCon. This will specify equality econstraints of parameters in data generation process.
  • maxDraw:The maximum number of random drawn parameters and misspecification model until all parameters in the model are eligible (no negative error variance, standardized coefficients over 1).
  • sequential:IfTRUE, use a sequential method to create data such that the data from factor are generated first and apply to a set of equations to obtain the data of indicators. IfFALSE, create data directly from model-implied mean and covariance of indicators.
  • facDist:ASimDataDistfor a distribution of factors. Use whensequentialisTRUE.
  • errorDist:ASimDataDistfor a distribution of measurement errors. Use whensequentialisTRUE
  • indDist:ASimDataDistfor a distribution of indicators. Use whensequentialisFALSE.
  • indLab:A vector of indicator names. If not specified, the variables names are y1, y2, ... .
  • modelBoot:IfTRUE, use a model-based bootstrap for data generation. See details for further information. This argument need a dataset in therealDataargument.
  • realData:The real dataset that the model based bootstrap will follow the distribution.
  • usedStd:IfSimModelOutis used for data generation, standardized parameters are used for data generation ifusedStd=TRUE. IfusedStd=FALSE, unstandardized parameters are used.

Details

This function will use mvrnorm function in MASS package to create data from model implied covariance matrix if the data distribution object (SimDataDist) is not specified. It the data distribution object is specified, the Gaussian copula model is used. See SimDataDist for further details. For the model-based bootstrap, the transformation proposed by Yung & Bentler (1996) is used. This procedure is the expansion from the Bollen and Stine (1992) bootstrap including a mean structure. The model-implied mean vector and covariance matrix with trivial misspecification will be used in the model-based bootstrap if misspec is specified. See page 133 of Bollen and Stine (1992) for a reference.

References

  • Bollen, K. A., & Stine, R. A. (1992). Bootstrapping goodness-of-fit measures in structural equation models.Sociological Methods and Research, 21,205-229.
  • Yung, Y.-F., & Bentler, P. M. (1996). Bootstrapping techniques in analysis of mean and covariance structures. In G. A. Marcoulides & R. E. Schumacker (Eds.),Advanced structural equation modeling: Issues and techniques(pp. 195-226). Mahwah, NJ: Erlbaum.

See Also

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(LY = LX, RPS = RPH, RTE = RTD)
SimData <- simData(CFA.Model, 200)
summary(SimData)
run(SimData)

# With Misspecification Model
n01 <- simNorm(0, 0.1)
error.cor.Mis <- matrix(NA, 6, 6)
diag(error.cor.Mis) <- 1
RTD.Mis <- symMatrix(error.cor.Mis, "n01")
CFA.Model.Mis <- simMisspecCFA(RTD=RTD.Mis)
SimData <- simData(CFA.Model, 200, misspec=CFA.Model.Mis)
summary(SimData)
run(SimData)

Run the code above in your browser using DataLab