compare_AICc: Compares the AICc of several outputs

View source: R/compare_AICc.R

compare_AICcR Documentation

Compares the AICc of several outputs

Description

This function is used to compare the AICc of several outputs obtained with the same data but with different set of parameters.
Each object must have associated logLik() method with df and nobs attributes.
AICc for object x will be calculated as 2*factor.value*logLik(x)+(2*attributes(logLik(x))$df*(attributes(logLik(x))$df+1)/(attributes(logLik(x))$nobs-attributes(logLik(x))$df-1).

Usage

compare_AICc(
  ...,
  factor.value = -1,
  silent = FALSE,
  FUN = function(x) specify_decimal(x, decimals = 2)
)

Arguments

...

Successive results to be compared as lists.

factor.value

The $value of the list object is multiplied by factor.value to calculate BIC.

silent

If TRUE, nothing is displayed.

FUN

Function used to show values

Details

compare_AICc compares the AICc of several outputs obtained with the same data.

Value

A list with DeltaAICc and Akaike weight for the models.

Author(s)

Marc Girondot marc.girondot@gmail.com

See Also

Other AIC: ExtractAIC.glm(), FormatCompareAIC(), compare_AIC(), compare_BIC()

Examples

## Not run: 
library("HelpersMG")
# Here two different models are fitted
x <- 1:30
y <- rnorm(30, 10, 2)+log(x)
plot(x, y)
d <- data.frame(x=x, y=y)
m1 <- lm(y ~ x, data=d)
m2 <- lm(y ~ log(x), data=d)
compare_BIC(linear=m1, log=m2, factor.value=-1)
# Here test if two datasets can be modeled with a single model
x2 <- 1:30
y2 <- rnorm(30, 15, 2)+log(x2)
plot(x, y, ylim=c(5, 25))
plot_add(x2, y2, col="red")
d2 <- data.frame(x=x2, y=y2)
m1_2 <- lm(y ~ x, data=d2)
x_grouped <- c(x, x2)
y_grouped <- c(y, y2)
d_grouped <- data.frame(x=x_grouped, y=y_grouped)
m1_grouped <- lm(y ~ x, data=d_grouped)
compare_AICc(separate=list(m1, m1_2), grouped=m1_grouped, factor.value=-1)
# Or simply
compare_AICc(m1=list(AICc=100), m2=list(AICc=102))

## End(Not run)

HelpersMG documentation built on Oct. 5, 2023, 5:08 p.m.