A fit from lm with a formula.
const data = { y: [4.2, 5.1, 6.3, 5.8, 7.9, 8.4, 6.1, 7.2], A: ["a", "a", "b", "b", "a", "a", "b", "b"], B: ["p", "q", "p", "q", "p", "q", "p", "q"] };
const t = Anova(lm("y ~ A * B", data, { contrasts: { A: "contr.sum", B: "contr.sum" } }), { type: 3 });
t.rowNames; // ["(Intercept)", "A", "B", "A:B", "Residuals"]
Type II or type III tests of the terms of a linear model. Equivalent to
car::Anova()in R. Ascar::Anova(fit, type = 2)ortype = 3for anlmfit: columnsSum Sq,Df,F value,Pr(>F); rows the terms (type III:(Intercept)first when the model has one) andResiduals.Type II tests each term after all the others except the terms that contain it (car's marginality; it does not depend on the contrasts). Type III tests each column set of the model's own matrix after all the other columns, so it depends on the contrasts (
contr.sumis the usual choice).Errors as car:
residual df = 0,residual sum of squares is 0 (within rounding error), and for type IIIthere are aliased coefficients in the model. Type II of a model with only an intercept gives the type III table with a warning.