Obtain fit measures for a model estimated with lavaan.survey

94 views
Skip to first unread message

Joshua Rosenberg

unread,
Jun 29, 2019, 8:25:07 PM6/29/19
to lavaan
Hi all, I have a question about Daniel Oberski's excellent lavaan.survey package; excuse me if this is off-topic for this forum.

If I fit a model, e.g.:

library(lavaan)
model
<- '
 # latent variable definitions
 ind60 =~ x1 + x2 + x3
 dem60 =~ y1 + a*y2 + b*y3 + c*y4
 dem65 =~ y5 + a*y6 + b*y7 + c*y8
'


fit
<- cfa(model, data=PoliticalDemocracy)
fit
.measures(fit)

Then fit measures for that fitted model will be returned.

But, if I add the following lines to adjust standard errors (to account for the grouping of observations using a hypothetical grouping variable), the same fit measures will be returned, whereas the output from the `summary()` method prints both the fit statistics for the original model and that with the adjusted standard errors.

library(lavaan.survey)group <- svydesign(ids = ~group, data = PoliticalDemocracy)
fit2
<- lavaan.survey(fit, group)

fit
.measures(fit2)

I checked the arguments available for `fit.measures()`, and there doesn't seem to be a way to request those from the model with the adjusted standard errors. Is there any way to obtain the fit measures from this adjusted model?



Terrence Jorgensen

unread,
Jun 30, 2019, 7:06:32 AM6/30/19
to lavaan
Did you know lavaan now offers cluster-robust SEs and tests?

fit <- cfa(model, data=PoliticalDemocracy, cluster = group)
fit
.measures(fit)

Is the problem that the function is called fitMeasures(), not fit.measures()?

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

Joshua Rosenberg

unread,
Jul 1, 2019, 10:52:36 AM7/1/19
to lavaan
Hi, thank you, I did not know about the cluster argument - that's very helpful!

The fit measures obtained from `fit.measures(fit)` seem to be associated with the normal/not cluster-robust SEs and tests. Do you know any way around this?

Terrence Jorgensen

unread,
Jul 2, 2019, 4:31:50 AM7/2/19
to lavaan
The fit measures obtained from `fit.measures(fit)`

Again, that is not a function name.  It returns an error for me, so if it works for you, you must be using a function from another package or that you have designed yourself.  The lavaan package's function is fitMeasures().

seem to be associated with the normal/not cluster-robust SEs and tests. Do you know any way around this?

I don't understand what you mean.  If you request cluster-robust SEs and tests, that is what you get.  

model <- '
    f =~ y1 + y2 + y3
    f ~ x1 + x2 + x3
'

fit
<- sem(model, data = Demo.twolevel, cluster = "cluster")
fit
.measures(fit) # returns an error
fitMeasures
(fit)  # returns both naive and scaled tests, and indices using both
summary
(fit, fit = TRUE)


The summary() output includes the naive and scaled tests/indices in separate columns.
Reply all
Reply to author
Forward
0 new messages