Closed jjesusfilho closed 7 years ago
Hi I am having a similar issue. Below is a reproducible example. I already asked for help in stack.exchange but had no answers so far:
Thanks for your time
library(lavaan)
library(semPlot)
table.7.5 <-read.table("http://www.da.ugent.be/datasets/Agresti2002.Table.7.5.dat",header=TRUE)
table.7.5$mental <- ordered(table.7.5$mental,levels = c("well","mild","moderate","impaired"))
model <- "mental ~ ses + life"
fit <- sem(model, data=table.7.5)
semPaths(fit,"std",edge.label.cex = 0.5, curvePivot=TRUE,layout = "tree")
Error message:
Error in colnames<-(*tmp*, value = "mental") : attempt to set 'colnames' on an object with less than two dimensions
Hi,
Someone helped me to solve the problem by replacing the content of cov by res.cov. I don't know why but when it's ordered data, Lavaan puts the implied covariance matrix in res.cov instead of cov.
All you have to do is this:
fit@SampleStats@cov<-fit@SampleStats@res.cov
Before calling:
semPaths(fit,"std",edge.label.cex = 0.5, curvePivot=TRUE,layout = "tree")
Let me know if it worked.
@jjesusfilho
Yes, it worked. Thanks a lot!
Did you report this bug to lavaan's developers?
I actually don't know if it's really a bug in Lavaan or an incompatibility between Lavaan and SemPlot. I wrote to Sacha but he never replied.
It's great to know that it worked for you.
2017-01-21 19:36 GMT-02:00 fsdias notifications@github.com:
@jjesusfilho https://github.com/jjesusfilho
Yes, it worked. Thanks a lot!
Did you report this bug to lavaan's developers?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SachaEpskamp/semPlot/issues/9#issuecomment-274289901, or mute the thread https://github.com/notifications/unsubscribe-auth/ALLi8SIlEFUE-DakefnxzIOQMjb1huFBks5rUnpxgaJpZM4Ld2qb .
-- José de Jesus Filho Doutorando - Fundação Getulio Vargas (EAESP-APG) (11) 2372-9811 (11) 98522-0210 http://www.josejesus.info
Thank you for reporting this. Please try the Github version now and it should work. Maintainance of semPlot lagged behind the past 1-2 years due to finishing my PhD and some other circumstances. I now have a new position in which I have to teach SEM, and I plan to start actively maintaining semPlot again.
Fix confirmed in the development version, thanks a lot!
Thank you very much.
2017-01-23 8:18 GMT-02:00 fsdias notifications@github.com:
Fix confirmed in the development version, thanks a lot!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SachaEpskamp/semPlot/issues/9#issuecomment-274449000, or mute the thread https://github.com/notifications/unsubscribe-auth/ALLi8U34NXie6N8zjEUlwEGWguoKxvpcks5rVH6EgaJpZM4Ld2qb .
-- José de Jesus Filho Doutorando - Fundação Getulio Vargas (EAESP-APG) (11) 2372-9811 (11) 98522-0210 http://www.josejesus.info
I have the following model . model<-"autonomo =~ v41+v19+v20+v18+v17 dialogal =~ v6+v5+v25+v4+v9 disciplinar =~ v2+v12+v15 punitivo =~ v3+v7+v10+v14+v11+v8\nautonomo + dialogal + disciplinar + punitivo ~ v43 + v44 + v45 + v46 + v47"
If I use semPaths(model), it works,
But If I try to plot it after fitting with ordered data, it doesnt:
fit<-cfa(model,data=data,ordered=names(data[1:42))
semPaths(fit)
I get the following error Error in
colnames<-
(*tmp*
, value = c("v41", "v19", "v20", "v18", "v17", : attempt to set 'colnames' on an object with less than two dimensionsBut If I try
fit<-cfa(model,data=data)
semPaths(fit), it works perfectly.
I can't understand why chaging the variables to ordered, it throws this error.