Skip to contents

Compare models fitted to the same catch and survey observations. Smaller values indicate a better balance between fit and model complexity. Marginal AIC assesses the model after integrating over its random effects. Conditional AIC (cAIC) assesses new observations sharing the fitted population and other random effects. Neither replaces hindcast evaluation of forecasting skill.

Usage

# S3 method for class 'tam_fit'
logLik(object, ...)

# S3 method for class 'tam_fit'
AIC(object, ..., k = 2)

cAIC(object, ..., details = FALSE)

Arguments

object

A fitted fit_tam() model.

...

Additional tam_fit models. For logLik(), currently unused.

k

Penalty per parameter for marginal AIC; the usual AIC uses 2.

details

Return a table including conditional log-likelihood, parameter counts and effective degrees of freedom (EDF)?

Value

logLik() returns a logLik object with df and nobs attributes. AIC() returns a number for one fit, or a standard df/AIC table for multiple fits. cAIC() returns a number for one fit, or a table sorted by increasing cAIC with EDF, cAIC and delta. With details = TRUE, it also includes conditional logLik, n_fixed, n_random, edf_fixed, edf_rec, edf_N, edf_F, edf_M, edf_other and edf_random. Single-model detailed output has delta = 0.

Details

Likelihood scale. Densities are evaluated on log observations, as in nll_fun(). No natural-scale lognormal Jacobian is added. Absolute values should not be compared with criteria calculated on a different response scale. Multiple-model calls require identical included observations and units.

Marginal AIC. logLik() returns the optimized Laplace approximation to the marginal log-likelihood. Its df counts all estimated outer parameters, including process SDs and correlations, after parameter maps are applied. Integrated latent states are not included in that count.

Conditional AIC. Equation 6 of Zheng, Cadigan and Thorson (2026) gives $$\mathrm{cAIC}=-2\ell_c+2p_c+2q-2\mathrm{tr}(H_j^{-1}H_r).$$ Here \(\ell_c\) is the observation log-likelihood at the fitted conditional mode, \(q\) is the number of integrated random coordinates, and \(H_j\) and \(H_r\) are random-coordinate Hessians of the joint and process/prior negative log-likelihoods. RTMB supplies derivatives; sparse Cholesky solves calculate the trace without forming a dense inverse.

edf_fixed is \(p_c\), the number of estimated outer parameters entering the conditional observation likelihood, identified using structural dependencies of observation predictions and SDs. It need not equal n_fixed: process-only parameters are excluded. The supplementary Gaussian example similarly excludes a prior-only parameter. This differs from the all-outer-parameter convention currently used by sdmTMB and WHAM. Counting follows tinyAM's fitted coordinates. Reparameterizations that move variance parameters into observation predictions can change this approximation.

edf_random equals \(q-\mathrm{tr}(H_j^{-1}H_r)\) and EDF equals edf_fixed + edf_random. Random EDF is partitioned by fitted coordinates: recruitment (log_r), N (log_n), F (log_f), M (log_m), and other coordinates, including latent initial abundance and Gaussian formula effects. These contributions sum to edf_random. Their allocation depends on the parameterization; they are accounting contributions rather than independent measures of support. Unusual contributions are warned about, not truncated.

Limitations. Intrinsic F/M/N random walks and latent initial abundance have unpenalized directions. Criteria are returned with warnings: marginal likelihood normalization is arbitrary, and comparisons between different unpenalized structures are particularly uncertain. Recruitment and formula random walks anchored at a fixed starting value are not intrinsically improper. Equation 6 assumes jointly Gaussian random effects; nonlinear stock-recruit and active cohort-survival constructions can violate this assumption despite Gaussian innovations. Their cAIC is an exploratory local approximation. Parameter boundaries and poor numerical convergence also limit the usual approximations. A singular or indefinite joint random Hessian prevents cAIC calculation; a singular process Hessian alone does not.

References

Zheng, N., Cadigan, N. G. and Thorson, J. T. (2026). A unifying theory for the evaluation of conditional Akaike information for mixed-effects models. Journal of Statistical Computation and Simulation. doi:10.1080/00949655.2026.2736799 . Equation 6 and supplementary R/TMB code.

Examples

if (FALSE) { # \dontrun{
fit <- fit_tam(cod_obs, years = 1983:2024, ages = 2:14)
alternative <- update(fit, F_settings = list(process = "ar1", mu_form = ~1))
AIC(fit, alternative)
cAIC(fit, alternative)
cAIC(fit, details = TRUE)
} # }