Add delta-AIC and Akaike weights to a comparison table
Source:R/model-selection.R
add_aic_weights.RdAdds deltaAIC and AICweight columns to a data frame that carries an AIC
column, and sorts the result so the best-supported model comes first.
Details
Akaike weights are only meaningful among models fitted to the same response
data. A table that mixes fits on different subsets — a Tweedie over all
hauls beside a Gamma over the positive ones, say, or a biomass model beside an
abundance model — has no common likelihood scale, and weights computed across
it would invite exactly the comparison the table should be warning against.
group exists for that case: weights are computed within each group, and left
NA for groups with a single member.
Examples
tab <- data.frame(
model = c("a", "b", "c"),
AIC = c(1002, 1000, 1010)
)
add_aic_weights(tab)
#> # A tibble: 3 × 4
#> model AIC deltaAIC AICweight
#> <chr> <dbl> <dbl> <dbl>
#> 1 b 1000 0 0.727
#> 2 a 1002 2 0.268
#> 3 c 1010 10 0.00490