Skip to contents

S3 method to compute AIC (Akaike Information Criterion).

Usage

# S3 method for class 'lifelihoodResults'
AIC(object, ..., k = length(coef(object)))

Arguments

object

output of lifelihood()

...

Ignored

k

Number of estimated parameter of the modèle. Default to length(coef(object)).

Value

The AIC

See also

Examples

library(lifelihood)
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#>  dplyr     1.1.4      readr     2.1.5
#>  forcats   1.0.0      stringr   1.5.1
#>  ggplot2   3.5.2      tibble    3.3.0
#>  lubridate 1.9.4      tidyr     1.3.1
#>  purrr     1.1.0     
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#>  dplyr::filter() masks stats::filter()
#>  dplyr::lag()    masks stats::lag()
#>  Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

df <- lifelihood::fakesample |>
  mutate(
    type = as.factor(type),
    geno = as.factor(geno)
  )

clutchs <- c(
  "clutch_start1", "clutch_end1", "clutch_size1",
  "clutch_start2", "clutch_end2", "clutch_size2"
)

dataLFH <- lifelihoodData(
  df = df,
  sex = "sex",
  sex_start = "sex_start",
  sex_end = "sex_end",
  maturity_start = "mat_start",
  maturity_end = "mat_end",
  clutchs = clutchs,
  death_start = "death_start",
  death_end = "death_end",
  covariates = c("geno", "type"),
  model_specs = c("gam", "lgn", "wei")
)

results <- lifelihood(
  lifelihoodData = dataLFH,
  path_config = get_config_path("config"),
  seeds = c(1, 2, 3, 4),
  raise_estimation_warning = FALSE
)
#> [1] "/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/Rtmp2lbF6M/temp_libpath1e0a2a79ba80/lifelihood/bin/lifelihood/Users/runner/work/Lifelihood/Lifelihood/lifelihood_1_2_3_4/temp_file_data_lifelihood.txt /Users/runner/work/Lifelihood/Lifelihood/lifelihood_1_2_3_4/temp_param_range_path.txt FALSE 0 25 FALSE 0 0 0 1 2 3 4 10 20 1000 0.3 NULL 2 2 50 1 1 0.001"
#> lifelihood Pascal program status code 0
AIC(results)
#> [1] 1298.819