Learn R Programming

simsem (version 0.2-8)

runFitParam: Build a parameter result object that the data-generation parameters are from the result of analyzing real data

Description

This function will analyze real data and use the result of the analysis to find the range of parameters used in data simulation.

Usage

runFitParam(model, nRep = 1000, misspec = new("NullSimMisspec"), 
maxDraw = 100, seed = 123321, usedStd = TRUE, ...)

Arguments

model
Model object used in analyzing the real and simulated data.
nRep
Number of replications.
misspec
Model misspecification matrices that are created by simMisspecCFA, simMisspecPath, or simMi
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).
seed
Seed number
usedStd
The standardized parameters are used for data generation if usedStd=TRUE. If usedStd=FALSE, unstandardized parameters are used.
...
The only additional argument is data, which is the real data that will be used in the analysis. The data argument is used when the model is linkS4class{SimModel}

Value

  • SimResultParam that saves the parameters and misspecification used in each replication.

Details

This function will use the obtained parameter estimates as the real population parameters in a simulation study, put a trivial model misspecification in the real parameters, and report the real and misspecified parameters in the SimResultParam object.

See Also

  • SimModelfor analysis model specification
  • SimResultfor the type of resulting object
  • runFitfor data simulation based on real data

Examples

Run this code
library(lavaan)
loading <- matrix(0, 9, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
model <- simParamCFA(LY=loading)
SimModel <- simModel(model, indLab=paste("x", 1:9, sep=""))
u2 <- simUnif(-0.2, 0.2)
loading.trivial <- matrix(NA, 9, 3)
loading.trivial[is.na(loading)] <- 0
LY.trivial <- simMatrix(loading.trivial, "u2")
mis <- simMisspecCFA(LY = LY.trivial)
Output <- runFitParam(SimModel, data=HolzingerSwineford1939, nRep=5, misspec=mis)
summary(Output)

out <- run(SimModel, HolzingerSwineford1939)
Output2 <- runFitParam(out, nRep=5, misspec=mis)

Run the code above in your browser using DataLab