Error if stand = TRUE and some loadings are constrained
ClaudiuPapasteri opened this issue · 1 comments
Hi,
Wonderful work on the package!
My observation stemmed from CFA. It seems that if you impose constraints on the model by fixing loadings/paths to be equal the data frame creation inside the functions throws an error. This happens only for standardized estimates stand = TRUE.
I hope this reproducible example helps:
bla <- 'mpg ~ a*cyl + a*disp + a*hp
qsec ~ disp + hp + wt'
blafit1 <- sem(bla, data = mtcars)
lavaanPlot(model = blafit1, # or just run lavaanPlot(model = blafit1, stand = TRUE)
graph_options = list(rankdir = "LR"),
node_options = list(shape = "box", fontname = "Helvetica"),
edge_options = list(color = "grey", fontsize = "10"),
coefs = TRUE, sig = 1.00, stars = "latent", covs = TRUE, stand = TRUE)
Error in `$<-.data.frame`(`*tmp*`, "lhs", value = c("mpg", "mpg", "mpg", :
replacement has 21 rows, data has 19
Thanks for the reproducible example, that certainly does help.
It seems the issue is that when you do stand = TRUE, I use standardizedsolution
to grab the parameter table for use in buildPaths
, but I clean up the variable names using the ParTable
object from the model itself, and for some reason the parameter table from the ParTable
object includes an entry for the parameter restrictions, whereas the one from standardizedsolution
does not, so there's 19 rows in the parameter table for that one, but I'm trying to get the clean variable names from the other one that includes the parameter restrictions as entries, and so has 21 rows. So to fix that I should be able to use the standardized solution table to get those correct names when you do stand = TRUE.
So there you go, I know you probably didn't need that level of detail, but this is mostly for me to remember this when I go back later to fix it.