exportData {simsem} | R Documentation |
Export data sets for analysis with outside SEM program.
Description
This function can be used to export data created from a set of parameters created from draw
, called a codeparamSet. This function can export data to be analyzed with either Mplus or LISREL.
Usage
exportData(nRep, model, n, program = "Mplus", fileStem = "sim", miss = NULL,
missCode = -999, datafun=NULL, pmMCAR = NULL, pmMAR = NULL, facDist = NULL,
indDist = NULL, errorDist = NULL, sequential = FALSE, modelBoot = FALSE,
realData = NULL, maxDraw = 50, misfitType = "f0", misfitBounds = NULL,
averageNumMisspec = NULL, optMisfit=NULL, optDraws = 50, seed = 123321,
silent = FALSE, multicore = FALSE, numProc = NULL, params = FALSE)
Arguments
nRep |
Number of replications. Users can specify as |
model |
|
n |
Sample size. This argument is not necessary except the user wish to vary sample size across replications. The sample size here is a vector of sample size in integers. For the random distribution object, if the resulting value has decimal, the value will be rounded. |
program |
Statistical program that will be used to analyze data. Currently only Mplys and LISREL are supported. |
fileStem |
The stem of the filename(s) for file(s) output. For example, a fileStem of "sim" will result in files named sim1.dat, sim2.dat, etc. |
miss |
Missing data handling template, created by the function |
missCode |
Missing data code, NA will be replaced by this value for all missing values in exported data. |
datafun |
Function to be applied to generated data set at each replication. |
pmMCAR |
The percent completely missing at random. This argument is not necessary except the user wish to vary percent missing completely at random across replications. The |
pmMAR |
The percent missing at random. This argument is not necessary except the user wish to vary percent missing at random across replications. The |
facDist |
A |
indDist |
A |
errorDist |
An object or list of objects of type |
sequential |
If |
modelBoot |
When specified, a model-based bootstrap is used for data generation. See |
realData |
A data.frame containing real data. The data generated will follow the distribution of this data set. |
maxDraw |
Integer specifying the maximum number of attempts to draw a valid set of parameters (no negative error variance, standardized coefficients over 1). |
misfitType |
Character vector indicating the fit measure used to assess the misfit of a set of parameters. Can be "f0", "rmsea", "srmr", or "all". |
misfitBounds |
Vector that contains upper and lower bounds of the misfit measure. Sets of parameters drawn that are not within these bounds are rejected. |
averageNumMisspec |
If |
optMisfit |
Character vector of either "min" or "max" indicating either maximum or minimum optimized misfit. If not null, the set of parameters out of the number of draws in "optDraws" that has either the maximum or minimum misfit of the given misfit type will be returned. |
optDraws |
Number of parameter sets to draw if optMisfit is not null. The set of parameters with the maximum or minimum misfit will be returned. |
seed |
Random number seed. Reproducibility across multiple cores or clusters is ensured using R'Lecuyer package. |
silent |
If |
multicore |
Use multiple processors within a computer. Specify as TRUE to use it. |
numProc |
Number of processors for using multiple processors. If it is |
params |
If |
Value
Text files saved to the current working directory. If program
= "Mplus" one file is output for each replication, and an extra file is output with the names of all saved data sets (this file can be used with the MONTECARLO command in Mplus). If program
= "LISREL" one file is output with each replication stacked on top of the next (this file can be used with the RP command in LISREL). If program
= TRUE
, a list of parameter values for each replication is returned.
Author(s)
Alexander M. Schoemann (East Carolina University; schoemanna@ecu.edu)
Examples
loading <- matrix(0, 6, 2)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
LY <- bind(loading, 0.7)
latent.cor <- matrix(NA, 2, 2)
diag(latent.cor) <- 1
RPS <- binds(latent.cor, 0.5)
RTE <- binds(diag(6))
VY <- bind(rep(NA,6),2)
CFA.Model <- model(LY = LY, RPS = RPS, RTE = RTE, modelType = "CFA")
## Export 20 replications to an external data file (not run).
#exportData(20, CFA.Model, 200)