式を指定した lm の当てはめです。
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 または Type III の、線形モデルの項の検定です。R の
car::Anova()と同等です。lmの当てはめにcar::Anova(fit, type = 2)またはtype = 3を使ったときと同じく、列はSum Sq、Df、F value、Pr(>F)で、行は項 (Type III では、モデルに切片があるときは先頭が(Intercept)) とResidualsです。Type II は、各項を、その項を含む項を除いた他のすべての項の後で検定します (car の周辺性。対比には依存しません)。Type III は、モデル自身の行列の各列の組を、他のすべての列の後で検定します。そのため対比に依存します (
contr.sumが通常の選択です)。エラーは car と同じです:
residual df = 0、residual sum of squares is 0 (within rounding error)、および Type III の場合のみthere are aliased coefficients in the model。切片だけのモデルの Type II は、警告つきで Type III の表になります。