Tests of nested GLMs
f_test.Rdf_test() is the F test of small within big,
F = (D_small - D_big) / (q phi_big) on F(q, n - p_big), for a family
whose dispersion is estimated; likelihood_ratio_test() the scaled
deviance drop (D_small - D_big) / phi_big on chi2(q), for one whose
dispersion is known (Poisson, binomial). They agree with
anova(small, big, test = "F") and test = "Chisq" (CAS Monograph 5,
section 6.2.1). The models are not checked to be nested: small's
columns must lie in the span of big's, on the same rows, family and
weights.
Arguments
- small, big
glm_fit()models,smallwith fewer coefficients.
Value
A list with statistic, df (q), df_resid (Inf for the
likelihood ratio test), deviance_drop and p_value.
Examples
d <- data.frame(y = c(1, 3, 2, 5, 4, 6, 8, 7), x = 1:8, z = c(0, 1, 0, 1, 1, 0, 1, 0))
f_test(glm_fit(y ~ x, d, "gaussian"), glm_fit(y ~ x + z, d, "gaussian"))$p_value
#> [1] 0.1650328