compare.fit {lcca} | R Documentation |
The generic method compare.fit
compares the achieved loglikelihood or
pseudo-loglikelihood values of nested
models fit by lca
, lcacov
or
lcca
.
compare.fit(obj1, ...) ## Default S3 method: compare.fit(obj1, ...) ## S3 method for class 'lca' compare.fit(obj1, obj2, ...) ## S3 method for class 'lcacov' compare.fit(obj1, obj2, ...) ## S3 method for class 'lcca' compare.fit(obj1, obj2, ...)
obj1 |
an object of class |
obj2 |
an object of the same class as |
... |
additional arguments to be passed to the methods. |
The two models represented by obj1
and obj2
must satisfy
the following criteria.
They should be produced by calls to the same function
(lca
, lcacov
or lcca
)
They should use the same set of response variables, with the same
terms appearing on the left-hand side of the formula
arguments.
Covariates on the right-hand sides of the model formulas do
not need to be the same.
They should be fit to the same set of cases (rows) of the data frame or model environment. Because missing values in covariates are handled by case deletion, models with different sets of covariates may have different sets of rows deleted.
They should have the same number of classes. Models with different number of classes are not comparable by usual likelihood-ratio procedures.
Frequencies supplied by the argument freq
should be
the same.
Sample design information supplied
by the arguments weights
, clusters
or strata
should be the same.
If weights
are not supplied to the model-fitting procedures,
then the models are compared by a likelihood-ratio test.
If weights
are supplied, the models are compared by
the pseudo likelihood-ratio test of Asparouhov and Muthen (2005).
Satisfying all the criteria above does not guarantee that the two models are nested and comparable by a (pseudo) likelihood-ratio test. Models with different sets of covariates on the right-hand sides of their respective formulas are nested only if every covariate in the smaller model is a linear combination of covariates in the larger model. It is ultimately up to the user to determine if the models are comparable.
One of the most common uses of compare.fit
is to test for
measurement invariance, to see if it is plausible that the
item-response probabilities (rho-parameters) are equal across subsets
of the population. This is done by calling lca
with a
groups
variable, setting constrain.rhos=TRUE
in one
model and constrain.rhos=FALSE
in the other, and then comparing
the results by compare.fit
.
A list with three components:
Chi.Sq |
test statistic comparing the null (smaller) model to the alternative (larger) model. |
df |
degrees of freedom for the test, equal to the number of free paramaters in the larger model minus the number of free parameters in the smaller model. |
p |
significance value for the test, with smaller values indicating greater evidence against the null model in favor of the alternative. |
Joe Schafer
Send questions to mchelpdesk@psu.edu
Asparouhov, T. and Muthen, B. (2005) Multivariate statistical modeling
with survey data. Proceedings of the Federal
Committee on Statistical Methodology (FCSM) Research
Conference. Washington, DC: Office of Management and Budget.
For more information on using this function and other functions in
the LCCA package, see the manual LCCA Package for R, Version 1
in the subdirectory doc
.
## recode variables in abortion attitudes dataset, ## setting NAP and DK to missing data(abortion) abortion$ABANY <- factor(abortion$ABANY, levels=c("YES","NO")) abortion$ABDEFECT <- factor(abortion$ABDEFECT, levels=c("YES","NO")) abortion$ABHLTH <- factor(abortion$ABHLTH, levels=c("YES","NO")) abortion$ABNOMORE <- factor(abortion$ABNOMORE, levels=c("YES","NO")) abortion$ABPOOR <- factor(abortion$ABPOOR, levels=c("YES","NO")) abortion$ABRAPE <- factor(abortion$ABRAPE, levels=c("YES","NO")) # fit separate three class models for men and women, using # sampling weights and a mild flattening constant for rhos set.seed(123) fit1 <- lca( cbind(ABANY,ABDEFECT,ABHLTH,ABNOMORE,ABPOOR,ABRAPE) ~ 1, weights=WTSSNR, flatten.rhos=1, data=abortion, nclass=3, groups=SEX) # test for equality of rho-parameters set.seed(123) fit2 <- lca( cbind(ABANY,ABDEFECT,ABHLTH,ABNOMORE,ABPOOR,ABRAPE) ~ 1, weights=WTSSNR, flatten.rhos=1, data=abortion, nclass=3, groups=SEX, constrain.rhos=TRUE) compare.fit( fit1, fit2 )