mplus_montecarlo_analysis_grm: A Function for Analyzing Monte Carlo Data Sets Created by...

View source: R/mplus_montecarlo_analysis_grm.R

mplus_montecarlo_analysis_grmR Documentation

A Function for Analyzing Monte Carlo Data Sets Created by mplus_montecarlo_data() or simdata_grm().

Description

This package contains the mplus_montecarlo_analysis_grm() function, which will analyze Monte Carlo data sets using the script files for various estimators. The data sets and the script files are generated by the mplus_montecarlo_data() function.

Usage

mplus_montecarlo_analysis_grm(
  model_object,
  estimators,
  rep,
  type_montecarlo,
  run_files
)

Arguments

model_object

A set of model specifications that can be passed from the function mplus_montecarlo_data() or simdata_grm().

estimators

A list of estimators. Available estimators are: c('ML_logit', 'ML_probit', 'MLR_logit', 'MLR_probit', 'MLF_logit', 'MLF_probit', 'WLS_delta', 'WLS_theta', 'WLSM_delta', 'WLSM_theta', 'WLSMV_delta', 'WLSMV_theta', 'ULS_delta', 'ULS_theta', 'ULSMV_delta', 'ULSMV_theta')

rep

a number of replication of data set if the analysis is done on each replicated data set separately. Null if type_montecarlo = TRUE.

type_montecarlo

if TRUE, the analysis is done using the type of MONTECARLO, which analyze all replications and give average parameters based on the number of replications.

run_files

if TRUE, it will execute the Mplus script files based on the selected estimators.

Value

mplus_montecarlo_analysis will analyze Monte Carlo data sets using the selected estimators. It uses MplusAutomation::runModels().

References

\insertRef

Asparaouhov2020MplusMontecarlo \insertRefHallquist2018MplusMontecarlo

Examples

library(MplusAutomation)
data.2F = mplus_montecarlo_data(
# list your model in increasing order
model = list(c(1,2,3,4), #factor 1
              c(5,6,7,8)) # factor 2
eloadval = NULL,
vloadings = c(0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5, 0.5), # a vector of factor loadings
thresholds = c(-2.478,	-1.818,	-0.865,	0.425), # threshold values per item for 1,2,3,4
factor.cor = NULL,# factor correlation
vfactor.cor = c(0.31), # length(vfactor.cor)
N = 300, # sample size
R = 5,# n of replications
seed_mplus = 4567,# seed number for Mplus
naming_data_files = 'data4_rep*.dat;',
file_dir = getwd(),
file_name = "generate_data4.inp",
run_files = TRUE
)

# running analysis as Monte Carlo type
setwd("C:/Users/Dell/mplus files")
mplus_montecarlo_analysis(
model_object = data.2F,
estimators = c('ULS_delta',
              'ULS_theta',
              'WLSMV_theta',
              'WLSMV_delta'),
rep = NULL,
type_montecarlo = TRUE,
run_files = TRUE)

# running each replicate separately to get theta values
#' setwd("C:/Users/Dell/mplus files")
mplus_montecarlo_analysis(
model_object = data.2F,
estimators = c('ULS_delta',
              'ULS_theta',
              'WLSMV_theta',
              'WLSMV_delta'),
rep = 1,
type_montecarlo = FALSE,
run_files = TRUE)

# running replicated data sets separately using loop
#' setwd("C:/Users/Dell/mplus files")
for (i in 1:10){
mplus_montecarlo_analysis(
model_object = data.2F,
estimators = c('ULS_delta',
              'ULS_theta',
              'WLSMV_theta',
              'WLSMV_delta'),
rep = i,
type_montecarlo = FALSE,
run_files = TRUE)
}

Boklauth/AUTTT documentation built on Dec. 9, 2022, 7:37 a.m.