Skip to contents

This function allows you to observe the ANOVA table for multiple ASReml or glmmTMB models.

Usage

anova_table(..., n_digits = 3)

Arguments

...

The models to use in the ANOVA table comparison

Their values may be:

  • asreml

  • glmmTMB

n_digits

numeric The number of digits to round results to.

Value

data.frame A dataframe containing all ANOVA tables. Can be used with xtable to produce a LaTeX table.

Examples

library(CBADASReml)
library(asreml)
test_data <- oats
test_data["yield2"] <- oats["yield"] * runif(nrow(oats["yield"]))
mod1 <- asreml(
    fixed = yield ~ Variety + Nitrogen + Variety:Nitrogen,
    random = ~ idv(Blocks) + idv(Blocks):idv(Wplots),
    residual = ~ idv(units),
    data = test_data
)
mod2 <- asreml(
    fixed = yield2 ~ Variety + Nitrogen + Variety:Nitrogen,
    random = ~ idv(Blocks) + idv(Blocks):idv(Wplots),
    residual = ~ idv(units),
    data = test_data
)
anova_table(mod1, mod2)
#>             Effect yield yield2
#> 1          Variety 0.226  0.387
#> 2         Nitrogen 0.000  0.054
#> 3 Variety:Nitrogen 0.936  0.681

## With glmmTMB models
library(glmmTMB)
Salamanders$count2 <- runif(nrow(Salamanders), 0, 10)
mod3 <- glmmTMB( # Zero inflated model
    count ~ spp * mined + (1 | site),
    zi = ~ spp * mined,
    data = Salamanders,
    family = nbinom2
)
#> Warning: Model convergence problem; singular convergence (7). See vignette('troubleshooting'), help('diagnose')
mod4 <- glmmTMB( # Hurdle model
    count2 ~ spp * mined + (1 | site),
    zi = ~ spp * mined,
    data = Salamanders,
    family = truncated_nbinom2
)
#> Warning: non-integer counts in a truncated_nbinom2 response variable
#> Warning: non-integer counts in a truncated_nbinom2 model
anova_table(mod3, mod4)
#>      Effect count count2
#> 1       spp 0.000  0.476
#> 2     mined 0.000  0.275
#> 3 spp:mined 0.012  0.510