A result of lmer (the object it returned, not a copy), or an array of at least two.
Optionaloptions: LmerAnovaOptions
For one fit type; for several refit and names.
// R: anova(lmerTest::lmer(y ~ x * f + (1 | g), data))
const data = {
y: [3.1, 4.0, 5.2, 6.8, 7.1, 8.3, 2.2, 3.5, 3.9, 5.9, 6.1, 7.4, 4.4, 5.0, 6.9, 3.0, 4.1, 4.9],
x: [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
f: ["u", "u", "v", "v", "u", "v", "u", "v", "v", "u", "v", "u", "v", "u", "u", "v", "u", "v"],
g: ["a", "a", "a", "b", "b", "b", "c", "c", "c", "d", "d", "d", "e", "e", "e", "f", "f", "f"],
};
const fit = lmer("y ~ x * f + (1 | g)", data);
const t = lmerAnova(fit);
t.terms; // ["x", "f", "x:f"]
t.numDF; // [1, 1, 1]
t.F; // [82.027, 0.44207, 0.53285]
// R: anova(lme4::lmer(y ~ x + (1 | g), data), fit)
const c = lmerAnova([lmer("y ~ x + (1 | g)", data), fit], { names: ["small", "full"] });
c.npar; // [4, 6]
c.Chisq; // [NaN, 0.6817]
c.messages; // ["refitting model(s) with ML (instead of REML)"]
The ANOVA table of a linear mixed model fitted by lmer, with Satterthwaite's denominator degrees of freedom
(lmerTest's anova()), or, given an array of fits, the likelihood-ratio comparison of the models (lme4's
anova() of several fits). Equivalent to lmerTest::anova() in R.
For one fit: each term of the fixed effects is tested jointly (an F-test of its hypothesis matrix, of Type III by
default, II or I as in lmerTest; see lmerContest for the test). Type III with an empty cell of an
interaction gives the message Missing cells for: .... A term without a test is listed last, with NaN.
For several fits (fitted to the same data object, with the same rows): REML fits are first refitted by maximum
likelihood (unless refit: false), the models are sorted by their number of parameters, and each is compared with
the one before by the likelihood-ratio test.
Optionaloptions: LmerCompareOptions
For one fit type; for several refit and names.
// R: anova(lmerTest::lmer(y ~ x * f + (1 | g), data))
const data = {
y: [3.1, 4.0, 5.2, 6.8, 7.1, 8.3, 2.2, 3.5, 3.9, 5.9, 6.1, 7.4, 4.4, 5.0, 6.9, 3.0, 4.1, 4.9],
x: [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
f: ["u", "u", "v", "v", "u", "v", "u", "v", "v", "u", "v", "u", "v", "u", "u", "v", "u", "v"],
g: ["a", "a", "a", "b", "b", "b", "c", "c", "c", "d", "d", "d", "e", "e", "e", "f", "f", "f"],
};
const fit = lmer("y ~ x * f + (1 | g)", data);
const t = lmerAnova(fit);
t.terms; // ["x", "f", "x:f"]
t.numDF; // [1, 1, 1]
t.F; // [82.027, 0.44207, 0.53285]
// R: anova(lme4::lmer(y ~ x + (1 | g), data), fit)
const c = lmerAnova([lmer("y ~ x + (1 | g)", data), fit], { names: ["small", "full"] });
c.npar; // [4, 6]
c.Chisq; // [NaN, 0.6817]
c.messages; // ["refitting model(s) with ML (instead of REML)"]
The ANOVA table of a linear mixed model fitted by lmer, with Satterthwaite's denominator degrees of freedom (lmerTest's
anova()), or, given an array of fits, the likelihood-ratio comparison of the models (lme4'sanova()of several fits). Equivalent tolmerTest::anova()in R.For one fit: each term of the fixed effects is tested jointly (an F-test of its hypothesis matrix, of Type III by default, II or I as in lmerTest; see lmerContest for the test). Type III with an empty cell of an interaction gives the message
Missing cells for: .... A term without a test is listed last, with NaN.For several fits (fitted to the same data object, with the same rows): REML fits are first refitted by maximum likelihood (unless
refit: false), the models are sorted by their number of parameters, and each is compared with the one before by the likelihood-ratio test.