Hi all,
I'm running a two-level SEM model in both R (lavaan) and Mplus and noticed some differences in the number of estimated parameters and degrees of freedom (df). I’d appreciate any insights on this.
R code
mod <-"
level:1
lris1W =~ dr_t1 + ss_t1 + pt_t1 + fb_t1 + gi_t1
lris2W =~ dr_t2 + ss_t2 + pt_t2 + fb_t2 + gi_t2
ae2W =~ ae8 + ae12 + ae16 + ae20
ae2W + lris2W ~ lris1W
# covariates
age =~ 1*Age
Age.x ~~ 0*Age
gndr =~ 1*Gender
Gender.x ~~ 0*Gender
ae2W + lris2W ~ age + gndr
level:2
lris1B =~ dr_t1 + ss_t1 + pt_t1 + fb_t1 + gi_t1
lris2B =~ dr_t2 + ss_t2 + pt_t2 + fb_t2 + gi_t2
ae2B =~ ae8 + ae12 + ae16 + ae20
ae2B + lris2B ~ lris1B
"
fit <- sem(mod, dataset, estimator = "MLR", cluster = "id", meanstructure = TRUE)
summary(fit, fit.measures = TRUE, standardized = TRUE, ci = TRUE)
Mplus code
CLUSTER IS id;
MODEL:
%WITHIN%
lris1W BY dr_t1 ss_t1 pt_t1 fb_t1 gi_t1;
lris2W BY dr_t2 ss_t2 pt_t2 fb_t2 gi_t2;
ae2W BY ae8 ae12 ae16 ae20;
ae2W lris2W ON lris1W;
! covariates
age BY Age@1;
Age@0;
gndr BY Gender@1;
Gender@0;
lris2W ae2W ON age gndr;
%BETWEEN%
lris1B BY dr_t1 ss_t1 pt_t1 fb_t1 gi_t1;
lris2B BY dr_t2 ss_t2 pt_t2 fb_t2 gi_t2;
ae2B BY ae8 ae12 ae16 ae20;
ae2B lris2B ON lris1B;
ANALYSIS:
TYPE = TWOLEVEL;
ESTIMATOR = MLR;
Output Comparison:
R (lavaan):
Parameters estimated: 87
Degrees of freedom: 170
Mplus:
Parameters estimated: 89
Degrees of freedom: 199
I reviewed the parameter listings and identified that Mplus includes 2 additional parameters—specifically, it appears to estimate a covariance between the two covariates (age and gender), which lavaan does not unless explicitly specified.
What’s puzzling to me is the larger difference in degrees of freedom (199 vs 170), even though the parameter count only differs by two. I'm wondering if this is due to how each software handles multilevel data structures.
Any thoughts on this discrepancy or suggestions on what else I should be checking?
Thanks for your attention.
Best,
Serena
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lavaan/147e8d10-bf98-4468-8ff9-22bf2647a173n%40googlegroups.com.