Object doesn't exist longInvariance function

17 views
Skip to first unread message

fotin...@gmail.com

unread,
Aug 3, 2018, 2:35:17 PM8/3/18
to lavaan
I am running the longInvariance function as follows:

#Model ER
> ModelER <- 'ERa =~ ER1 + ER2 + ER3 + ER4 + ER5 + ER6 ERb =~ ER7 + ER8 + ER9 ERc =~ ER9 + ER10 + ER11'

#create list of variables
> ERa1 <- c("ER1", "ER2", "ER3", "ER4", "ER5")
> ERb2 <- c("ER6", "ER7", "ER8")
> ERC3 <- c("ER9", "ER10", "ER11")
> constrainedVarER <- list(ERa1, ERb2, ERC3)

longInvariance(ModelER, data = imputeFM, auto = 1, constrainAuto = TRUE, strict = TRUE, varList = constrainedVarER, data = exLong, estimator = "WLSMV", method = "satorra.bentler.2010")

and I get the following error:

Error in ~ER7 + ER8 + ER9ERc = ~ER9 + ER10 + ER11 : 
  object 'ER8' not found

I also ran this to check
str(ModelER)
 chr "ERa =~ ER1 + ER2 + ER3 + ER4 + ER5 + ER6 ERb =~ ER7 + ER8 + ER9 ERc =~ ER9 + ER10 + ER11"

I have used ER8 for cfa function so it is there but why is this code not recognising it?

Can anyone help?

Terrence Jorgensen

unread,
Aug 7, 2018, 7:38:22 AM8/7/18
to lavaan
> ModelER <- 'ERa =~ ER1 + ER2 + ER3 + ER4 + ER5 + ER6 ERb =~ ER7 + ER8 + ER9 ERc =~ ER9 + ER10 + ER11'

Make sure you add a line break for each formula

ModelER <- '
ERa =~ ER1 + ER2 + ER3 + ER4 + ER5 + ER6
ERb =~ ER7 + ER8 + ER9
ERc =~ ER9 + ER10 + ER11
'


#create list of variables
> ERa1 <- c("ER1", "ER2", "ER3", "ER4", "ER5")
> ERb2 <- c("ER6", "ER7", "ER8")
> ERC3 <- c("ER9", "ER10", "ER11")
> constrainedVarER <- list(ERa1, ERb2, ERC3)

This won't work.  You have 6 indicators on the first occasion, but only 3 on the other occasions.  So which items are the same item repeatedly measured?  

This is a limiting assumption of the longInvariance() function that I am trying to get around by writing a more general invariance function.  You are also using WLSMV -- does that mean you have categorical indicators?  longInvariance() currently only works for continuous indicators (another limitation I am working on).  Even if you could use categorical data, the MV-adjustment to the chi-squared test implies that you should use method = "satorra.2000"

longInvariance(ModelER, data = imputeFM, auto = 1, constrainAuto = TRUE, strict = TRUE, varList = constrainedVarER, data = exLong, estimator = "WLSMV", method = "satorra.bentler.2010")

Why are you using the data= argument twice?  Did you just forget to remove data = exLong from the help-page example?

If imputeFM is a list of imputed data sets, that will not work either (another limitation I am working on).

Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Terrence Jorgensen

unread,
Aug 26, 2018, 6:06:41 PM8/26/18
to lavaan
(another limitation I am working on).

There is a new function in the development version, which addresses all of the limitations I pointed out earlier this month.  

Reply all
Reply to author
Forward
0 new messages