Generating Mplus Input Files
Ivan Jacob Agaloos Pesigan
Source:vignettes/sim-input.Rmd
sim-input.Rmd
The FitCULTA1Profile
, FitCULTA2Profiles
,
and FitCULTA3Profiles
functions require that
Mplus is installed on the system.
In contrast, the InputCULTA1Profile
and
InputCULTA2Profiles
functions only generate
Mplus-compatible data and input files. These files can be transferred
and run on another machine with Mplus installed.
The accompanying vignette demonstrates the use of the
InputCULTA1Profile
and InputCULTA2Profiles
functions for preparing and exporting the necessary Mplus
files.
The workflow proceeds as follows:
- Generate the data.
-
Use the
InputCULTA*
functions to create Mplus-compatible data and input files. - Transfer and run the generated files on a system where Mplus is installed.
Data Generation
# complete list of R function arguments
# random seed for reproducibility
set.seed(42)
# dimensions
n # number of individuals
#> [1] 10000
m # measurement occasions
#> [1] 6
p # number of items
#> [1] 4
q # common trait dimension
#> [1] 1
# covariate parameters
mu_x
#> [1] 11.4009
sigma_x
#> [1] 24.67566
# profile membership and transition parameters
nu_0
#> [1] -3.563
kappa_0
#> [1] 0.122
alpha_0
#> [1] -3.586
beta_00
#> [1] 2.25
gamma_00
#> [1] 0.063
gamma_10
#> [1] 0.094
# trait parameters
psi_t
#> [,1]
#> [1,] 0.1
mu_t
#> [1] 0
psi_p
#> [,1] [,2] [,3] [,4]
#> [1,] 0.1 0.0 0.0 0.0
#> [2,] 0.0 0.1 0.0 0.0
#> [3,] 0.0 0.0 0.5 0.0
#> [4,] 0.0 0.0 0.0 0.5
mu_p
#> [1] 0 0 0 0
common_trait_loading
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
# state parameters
common_state_loading
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
phi_0
#> [1] 0
phi_1
#> [1] 0.311
psi_s0
#> [1] 1
psi_s
#> [1] 0.25
theta
#> [,1] [,2] [,3] [,4]
#> [1,] 0.15 0.00 0.00 0.00
#> [2,] 0.00 0.15 0.00 0.00
#> [3,] 0.00 0.00 0.15 0.00
#> [4,] 0.00 0.00 0.00 0.15
# profile-specific means
mu_profile
#> [,1] [,2]
#> [1,] 2.253 -0.278
#> [2,] 1.493 -0.165
#> [3,] 1.574 -0.199
#> [4,] 1.117 -0.148
data <- GenCULTA2Profiles(
n = n,
m = m,
mu_x = mu_x,
sigma_x = sigma_x,
nu_0 = nu_0,
kappa_0 = kappa_0,
alpha_0 = alpha_0,
beta_00 = beta_00,
gamma_00 = gamma_00,
gamma_10 = gamma_10,
mu_t = mu_t,
psi_t = psi_t,
mu_p = mu_p,
psi_p = psi_p,
common_trait_loading = common_trait_loading,
common_state_loading = common_state_loading,
phi_0 = phi_0,
phi_1 = phi_1,
psi_s0 = psi_s0,
psi_s = psi_s,
theta = theta,
mu_profile = mu_profile
)
Generate Mplus Files
In this stage, we generate the Mplus-compatible data and input files
using the InputCULTA1Profile
,
InputCULTA2Profiles
, InputLTA2Profiles
, and
InputRILTA2Profiles
functions. These functions take the
simulated dataset and export the necessary files to run the model in
Mplus
.
Each function corresponds to a specific version of the CULTA model:
InputCULTA1Profile(data = data)
#> Check data and Mplus input files in
#> /scratch/ibp5092/manCULTA/vignettes/cutsar_WKayjJr5WUxgJyKTtzXU
InputCULTA2Profiles(data = data)
#> Check data and Mplus input files in
#> /scratch/ibp5092/manCULTA/vignettes/culta_ov5hJdvrSBedH3XIxwW0
InputLTA2Profiles(data = data)
#> Check data and Mplus input files in
#> /scratch/ibp5092/manCULTA/vignettes/lta_SPiCltiQICpKB3TeB1br
InputRILTA2Profiles(data = data)
#> Check data and Mplus input files in
#> /scratch/ibp5092/manCULTA/vignettes/rilta_Fp17CqRi4u9Q45VhC2La
Run in Mplus
In the final stage, the Mplus-compatible data and input files
generated by the InputCULTA1Profile
,
InputCULTA2Profiles
, InputLTA2Profiles
, and
InputRILTA2Profiles
functions can be transferred to a
machine where Mplus
is installed.
To run the model:
- Open
Mplus
on the target system. - Load the generated
.inp
(input) file. - Execute the model to produce the desired output, including parameter
estimates, fit statistics, and saved results (e.g.,
TECH3
,TECH4
, andCPROBS
).
This stage completes the workflow by fitting the CULTA model using the fully prepared files from earlier stages.