# simple example of a model using builtin data
# demonstrates use
test <- mplusObject(
TITLE = "test the MplusAutomation Package and my Wrapper;",
MODEL = "
mpg ON wt hp;
wt WITH hp;",
usevariables = c("mpg", "wt", "hp"),
rdata = mtcars)
res <- mplusModeler(test, "mtcars.dat", modelout = "model1.inp", run = 1L)
# remove files
unlink("mtcars.dat")
unlink("model1.inp")
unlink("model1.out")
# similar example using a robust estimator for standard errors
test2 <- update(test, ANALYSIS = ~ "ESTIMATOR = MLR;")
res2 <- mplusModeler(test2, "mtcars.dat", modelout = "model2.inp", run = 1L)
unlink("mtcars.dat")
unlink("model2.inp")
unlink("model3.out")
# now use the built in bootstrapping methods
# note that these work, even when Mplus will not bootstrap
res3 <- mplusModeler(test2, "mtcars.dat", modelout = "model3.inp", run = 10L)
unlink("mtcars.dat")
unlink("model3.inp")
unlink("model3.out")
unlink("Mplus Run Models.log")
Run the code above in your browser using DataLab