yrosseel/lavaan

Dummy code & LAMBDA indices not adjusting when estimating latent interactions in SAM

E-M-McCormick opened this issue · 2 comments

This stems from a conversation I had with Yves at Working Group SEM in Twente - really appreciate the help!

A bit of background, we have a linear growth model with a observed distal outcome (z) where we want to include bilinear (int:slp) and quadratic (int:int & slp:slp) interactions of the growth factors. The main error we get is Error in LAMBDA[[b]][cbind(dummy.ov.idx, dummy.lv.idx)] <- 1 : subscript out of bounds which when we debugged (using debug(lavaan:::lav_sam_step1_local)) was coming because the indexes do not re-adjust when the dummy latent interaction column in LAMBDA is removed. When this column is removed the model tries to reference the distal outcome column as 4 instead of 3, which is then out of bounds. We tried to specify z as a latent variable explicitly fz but this did not solve the issue. See the attached zip file for a MRE with R code for generated data and model syntax. Happy to clarify further if anything is unclear.

SAM-Dummy-Code-MRE.zip

Thanks for the reprex. This should work now with the github version. Let me know if you still get issues.