Hi,
I have a (hopefully) basic question. I want to define variables to use for an analysis but am struggling with the proper syntax. Here is a simple example using the HolzingerSwineford1939 data from the lavaan package to create three composite variables (a,b,c).
library(MplusAutomation)
library(lavaan)
script1 = mplusObject(
TITLE = "Example #1 - Factor Model;",
MODEL = "f1 by a b c;",
usevariables = c("a", "b", "c"),
DEFINE = "a=sum(x1-x3); b=sum(x4-x6); c=sum(x7-x9);",
rdata = HolzingerSwineford1939)
fit <- mplusModeler(script1, modelout = "deleteme.inp", run=1)
Script1 runs successfully, but when I attempt to run the "fit" script I receive the following error message:
Error in `[.data.frame`(df, , keepCols, drop = FALSE) :
undefined columns selected
I'm guessing this must be a basic syntax error, but I couldn't find any examples online of using the define command.
Any suggestions on where my code goes off?
Thank you so much!