Main Content

**Class: **LinearMixedModel

Compare linear mixed-effects models

returns the results of a likelihood ratio
test that compares the linear mixed-effects models
`results`

= compare(`lme`

,`altlme`

)`lme`

and `altlme`

. Both models must use
the same response vector in the fit and `lme`

must be nested in
`altlme`

for a valid theoretical likelihood ratio test.
Always input the smaller model first, and the larger model second.

`compare`

tests the following null and alternate
hypotheses:

*H*_{0}: Observed response vector is
generated by `lme`

.

*H*_{1}: Observed response vector is
generated by model `altlme`

.

It is recommended that you fit `lme`

and
`altlme`

using the maximum likelihood (ML) method prior to
model comparison. If you use the restricted maximum likelihood (REML) method,
then both models must have the same fixed-effects design matrix.

To test for fixed effects, use `compare`

with the simulated likelihood ratio
test when `lme`

and `altlme`

are
fit using ML or use the `fixedEffects`

,
`anova`

, or `coefTest`

methods.

also returns the results of a likelihood ratio test that compares linear
mixed-effects models `results`

= compare(___,`Name,Value`

)`lme`

and `altlme`

with
additional options specified by one or more `Name,Value`

pair
arguments.

For example, you can check if the first input model is nested in the second input model.

`[`

returns the results of a simulated likelihood ratio test that compares linear
mixed-effects models `results`

,`siminfo`

]
= compare(`lme`

,`altlme`

,'NSim',`nsim`

)`lme`

and
`altlme`

.

You can fit `lme`

and `altlme`

using ML or
REML. Also, `lme`

does not have to be nested in
`altlme`

. If you use the restricted maximum likelihood
(REML) method to fit the models, then both models must have the same
fixed-effects design matrix.

`[`

also returns the results of a simulated likelihood ratio test that compares
linear mixed-effects models `results`

,`siminfo`

]
= compare(___,`Name,Value`

)`lme`

and `altlme`

with additional options specified by one or more `Name,Value`

pair arguments.

For example, you can change the options for performing the simulated
likelihood ratio test, or change the confidence level of the confidence interval
for the *p*-value.

[1] Hox, J. *Multilevel Analysis, Techniques and
Applications*. Lawrence Erlbaum Associates, Inc., 2002.

[2] Stram D. O. and J. W. Lee. “Variance components testing in the
longitudinal mixed-effects model”. *Biometrics*, Vol. 50, 4,
1994, pp. 1171–1177.

`anova`

| `covarianceParameters`

| `fitlme`

| `fitlmematrix`

| `fixedEffects`

| `LinearMixedModel`

| `randomEffects`