Create Tibble from List of Anovas
anova_tbl.Rd
Create a tibble from a list of anovas that compare a model to the null model or that compare two nested models.
Arguments
- anova_ls
a
list
ofanova
objects.
Value
An object of classes "anova_tbl"
, "announce"
, inheriting from tibble
, showing the
table entries for each anova, one per line.
Details
The anovas to be compared must all be of the same type i.e., all must be analyses of a single model object or all must be comparisons of two models. If any of the models has more than one independent variable, the results may be difficult to interpret and a warning will be given.
anova_tbl()
can be used to be easily and conveniently compare a list of anovas obtained with
summanov
and list_transpose
, see examples.
See also
anova.glm()
list_transpose()
, and
tibble
.
Other comp_glm:
comp_glm()
,
summanov()
,
univ_anova()
Examples
## Following on from summanov() examples…
## Simulate Bernoulli data
(d <- list(
iv2 = list(g = c("a", "c", "e"), h = c("b", "d", "f")),
iv3 = list(i = c("a", "b", "c"), j = c("d", "e", "f")),
iv4 = list(k = c("a", "b"), l = c("c", "d"), m = c("e", "f"))
) |> add_grps(binom_data(levels = 6), iv, .key = _))
#> __________________________
#> Simulated Binomial Data: -
#>
#> # A tibble: 6 × 6
#> iv iv2 iv3 iv4 pn qn
#> <fct> <fct> <fct> <fct> <int> <int>
#> 1 a g i k 35 31
#> 2 b h i k 38 28
#> 3 c g i l 24 42
#> 4 d h j l 10 56
#> 5 e g j m 9 57
#> 6 f h j m 8 58
## Create list of GLM anovas using summanov()
(alist <- d |> summanov(cbind(pn, qn), starts_with("iv")) |>
list_transpose() |> _$anova)
#> $iv
#> ____________
#> GLM Anova: -
#>
#> Analysis of Deviance Table
#>
#> Model: binomial, link: logit
#>
#> Response: cbind(pn, qn)
#>
#> Terms added sequentially (first to last)
#>
#>
#> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
#> NULL 5 67.071
#> iv 5 67.071 0 0.000 4.165e-13 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> $iv2
#> ____________
#> GLM Anova: -
#>
#> Analysis of Deviance Table
#>
#> Model: binomial, link: logit
#>
#> Response: cbind(pn, qn)
#>
#> Terms added sequentially (first to last)
#>
#>
#> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
#> NULL 5 67.071
#> iv2 1 1.6927 4 65.378 0.1932
#>
#> $iv3
#> ____________
#> GLM Anova: -
#>
#> Analysis of Deviance Table
#>
#> Model: binomial, link: logit
#>
#> Response: cbind(pn, qn)
#>
#> Terms added sequentially (first to last)
#>
#>
#> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
#> NULL 5 67.071
#> iv3 1 60.159 4 6.912 8.75e-15 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> $iv4
#> ____________
#> GLM Anova: -
#>
#> Analysis of Deviance Table
#>
#> Model: binomial, link: logit
#>
#> Response: cbind(pn, qn)
#>
#> Terms added sequentially (first to last)
#>
#>
#> Df Deviance Resid. Df Resid. Dev Pr(>Chi)
#> NULL 5 67.071
#> iv4 2 58.781 3 8.290 1.721e-13 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
## Tibble from list of GLM anovas
alist |> anova_tbl()
#> _________________________________________________
#> Analysis of Deviance (Comparing to null model): -
#>
#> # A tibble: 4 × 9
#> Name `Null Df` `Null Dev` Df Deviance `Resid. Df` `Resid. Dev` `Pr(>Chi)`
#> * <chr> <int> <dbl> <int> <dbl> <int> <dbl> <dbl>
#> 1 iv 5 67.1 5 67.1 0 1.55e-15 4.16e-13
#> 2 iv2 5 67.1 1 1.69 4 6.54e+ 1 1.93e- 1
#> 3 iv3 5 67.1 1 60.2 4 6.91e+ 0 8.75e-15
#> 4 iv4 5 67.1 2 58.8 3 8.29e+ 0 1.72e-13
#> # ℹ 1 more variable: sig <fct>
## Add GLM anova with two independent variables
alist$iv3_iv4 <- glm(cbind(pn, qn) ~ iv3 + iv4, family = binomial, data = d) |>
anova()
## Tibble from list with multivariable anova invokes warning
try(alist |> anova_tbl())
#> Warning: iv3_iv4 has > 1 independent variable, interpret with caution
#> _________________________________________________
#> Analysis of Deviance (Comparing to null model): -
#>
#> # A tibble: 5 × 9
#> Name `Null Df` `Null Dev` Df Deviance `Resid. Df` `Resid. Dev` `Pr(>Chi)`
#> * <chr> <int> <dbl> <int> <dbl> <int> <dbl> <dbl>
#> 1 iv 5 67.1 5 67.1 0 1.55e-15 4.16e-13
#> 2 iv2 5 67.1 1 1.69 4 6.54e+ 1 1.93e- 1
#> 3 iv3 5 67.1 1 60.2 4 6.91e+ 0 8.75e-15
#> 4 iv4 5 67.1 2 58.8 3 8.29e+ 0 1.72e-13
#> 5 iv3_i… 5 67.1 1 60.2 4 6.91e+ 0 8.75e-15
#> # ℹ 1 more variable: sig <fct>
rm(d, alist)