← All resources

Akaike Information Criterion (AIC): Formula, Meaning, Examples

14 min read
Akaike Information Criterion (AIC): Formula, Meaning, Examples

Akaike Information Criterion (AIC): Formula, Meaning, Examples

Researcher comparing statistical model results at a desk

The Akaike information criterion (AIC) ranks statistical models fitted to the same data by balancing how well each fits against how many parameters it uses. The formula is AIC = 2k − 2 ln(L̂), where k is the number of estimated parameters and L̂ is the model’s maximized likelihood (Wikipedia). Lower is better, but only differences between models mean anything, and the number never tells you whether the winning model is actually good. This guide covers the calculation, a worked example, interpretation, AICc, AIC versus BIC, and how to run and report AIC in R or Python so a supervisor or reviewer can reproduce it.

Plotstudio
Make Model Comparisons Reproducible
PlotStudio AI supports research workflows in R and Python, with code, methods, outputs, and statistics available for review.
Visit

TL;DR

  • AIC = −2 ln(L̂) + 2k. It estimates relative information lost by each candidate model, so the model with the lowest AIC is preferred.
  • Raw AIC values are meaningless alone. Compare ΔAIC (each model minus the minimum) across models fitted to exactly the same data and response.
  • Use AICc when the sample is small relative to the number of parameters. AIC is not a hypothesis test, so do not call results “significant”.
  • AIC favors prediction and tends to accept more parameters than BIC, whose penalty grows with sample size.
  • Report the candidate set, the software, the parameter count convention and ΔAIC or Akaike weights, so the selection can be reproduced.

Table of Contents

What the Akaike information criterion measures

Hirotugu Akaike introduced AIC in 1973 as an extension of the maximum likelihood principle. It combined parameter estimation with the choice of model structure in one procedure, and a 2019 review in WIREs Computational Statistics describes it as the first model selection criterion to gain widespread acceptance.

The idea is simple. A model with more parameters will almost always fit the data in hand better, even when the extra terms are chasing noise. AIC has two components: −2ℓ is the deviance, a measure of misfit, and 2k is the complexity penalty. A new parameter earns its place only if it lowers the deviance by more than 2.

AIC balances model misfit against complexity penalty

The theory behind the penalty is about prediction. Portet’s 2020 primer derives AIC from an asymptotically unbiased estimator of expected relative Kullback–Leibler divergence, a measure of how much information is lost when a candidate model stands in for the process that generated the data. Oehlert makes the same point in plain terms: the in-sample log-likelihood is biased high by the number of fitted parameters, and AIC subtracts that bias to estimate how well the model would do on future data. That is why AIC is a predictive criterion, not a truth-finding one.

How AIC is calculated

The general form is:

AIC = −2 ln(L̂) + 2k

  • ln(L̂) is the maximized log-likelihood, which any maximum likelihood fit reports.
  • k is the number of estimated parameters. For a linear regression this includes the intercept, every slope and the error variance (Portet, 2020).

The best model in your candidate set is the one with the minimum AIC.

A worked example with two models

A professional guide to parsimonious models gives an illustrative comparison with n = 100 observations:

Model A (2 predictors) Model B (5 predictors)
Parameters (k) 4 7
−2 log L 427.30 417.29
AIC 435.30 431.29
BIC 445.72 449.52

Model B fits better, with a deviance about 10 units lower. Its three extra parameters cost 6 units of penalty under AIC, so its AIC ends up 4.01 lower. AIC prefers Model B. BIC prefers Model A by 3.80, because at n = 100 its penalty per parameter is ln(100) ≈ 4.6, well above AIC’s 2.

The two criteria are not contradicting each other. They answer different questions, as the AIC versus BIC section below explains.

How to interpret an AIC value

Only differences matter

Portet stresses that actual AIC values have no meaning on their own. An AIC of 431 is not good and an AIC of 62 is not better. The unit is relative information, and the scale depends on your data.

So compute ΔAIC: each model’s AIC minus the smallest AIC in the set. The best model gets ΔAIC = 0. The Turku PET Centre guide makes the same point: only differences, not raw values, are interpretable as strength of evidence.

In the worked example, ΔAIC for Model B is 0 and for Model A is 4.01.

Rules of thumb for ΔAIC

Portet, citing Burnham and Anderson (2002), gives these guidelines (source):

ΔAIC Support for the model
0 to 2 Substantial
4 to 7 Considerably less
More than 10 Essentially none

Treat these as guides, not cutoffs. In the Knox College course example of coin-flip models, the best of three link functions beat the others by less than 5, so the authors conclude it is not sufficiently better to ignore the rest.

Akaike weights

Akaike weights turn ΔAIC into relative support: weight = exp(−ΔAIC/2) divided by the sum of that quantity over all models. Portet describes them as the probability that a model is the best one given the data and the candidate set, and suggests a single best model can be accepted when its weight exceeds 0.9 (source).

For the worked example: Model A gives exp(−2.005) ≈ 0.135 and Model B gives 1, so the weights are about 0.88 for B and 0.12 for A. That is a clear lean toward B, short of the 0.9 bar. A reviewer would expect you to say so rather than declare B the winner outright.

What AIC does not tell you

  • It is not a test. Information criteria are not null hypothesis tests, so avoid saying a model was “significant” or that another was “rejected” (Turku PET Centre).
  • It gives no warning when every candidate is poor. AIC only ranks the set you supply. After selection, check absolute quality with residual diagnostics and tests of the model’s predictions. Our guide to interpreting regression output covers those checks.
  • The winner is not “the truth”. It is the best of the models you thought to fit (Portet, 2020).
  • The data must be identical. AIC values are comparable only for models fitted to exactly the same observations and the same response. Transforming the outcome or dropping rows for one model breaks the comparison. The Knox College example makes the same point: the dependent variable values must be exactly the same across models. Missing values are the usual trap: if one model has an extra covariate with missing entries, the software silently fits it on fewer rows.

Model ranking by a fit-versus-complexity trade-off also appears in applied forecasting, for example in AI score predictions today for football, where competing prediction approaches have to be compared on the same matches.

When to use AICc instead of AIC

AIC’s penalty is derived for large samples. With few observations relative to parameters, it under-penalizes complexity and favors overfit models. The small-sample correction is:

AICc = AIC + 2K(K+1) / (N − K − 1)

Portet recommends AICc when K > N/40, and other guides, citing Burnham and Anderson, use the equivalent rule n/k < 40. AICc is undefined when N − K − 1 is zero or negative (Portet, 2020). The correction shrinks toward zero as N grows, so using AICc by default costs you nothing in large samples.

This matters for the typical study in a thesis: a pilot trial with 60 patients, a lab experiment with 40 participants, or a panel with few clusters. With 60 observations, a model with 3 or more parameters is already over the n/k < 40 line. Switch to AICc and say so in the methods.

When to use AICc instead of AIC

AIC versus BIC

The Bayesian information criterion (BIC) has the same structure with a different penalty: instead of 2 per parameter, it charges ln(n) per parameter. Once n exceeds about 8, ln(n) is larger than 2, so BIC penalizes complexity more heavily and favors simpler models. In the worked example above, the extra 4.6 per parameter at n = 100 flipped the preference.

The practical difference is the goal:

AIC BIC
Penalty per parameter 2 ln(n)
Orientation Predictive accuracy on new data Identifying the data-generating model, if it is in the set
Tends to select Larger models Smaller models, increasingly so as n grows
Use when You want forecasts, risk scores or a flexible description You have a theory-driven question about which structure is correct

The predictive orientation of AIC is well documented (Cavanaugh and Neath, 2019). When AIC and BIC disagree, do not pick whichever flatters your hypothesis. Decide before the analysis which goal applies, state it, and report both if the choice is not obvious. Our article on Bayesian versus frequentist statistics gives the wider context, and the framework in machine learning model selection shows how cross-validation fits alongside information criteria.

AIC in R

Base R computes AIC and BIC for any model with a log-likelihood, and accepts several fitted models at once:

m1 <- lm(outcome ~ age + treatment, data = d)
m2 <- lm(outcome ~ age + treatment + baseline + site, data = d)
AIC(m1, m2)
BIC(m1, m2)

For a full table, the bbmle package’s ICtab function computes AIC, BIC, AICc and related criteria for a series of models. It returns the criterion, degrees of freedom, the difference from the best model (dIC) and Akaike weights. By default it reports differences rather than raw values, reflecting the view that raw values are rarely worth reporting. Use type = "AICc" and pass the sample size when a small-sample correction applies.

Oehlert’s University of Minnesota R examples show the same workflow on real data: AIC computed for a null model, a full model and a restricted model, where the criterion slightly prefers the full model over a mean-zero model.

AIC in Python

In Python, fitted statsmodels results expose aic and bic attributes. For a quick comparison:

import statsmodels.formula.api as smf

m1 = smf.ols("outcome ~ age + treatment", data=d).fit()
m2 = smf.ols("outcome ~ age + treatment + baseline + site", data=d).fit()
print(m1.aic, m2.aic)

One trap when moving between languages: software counts k differently. R counts the error variance as a parameter, so k = p + 2 for a regression with an intercept, while statsmodels OLS uses p + 1. AIC values for the same model therefore differ by a constant. The constant cancels when you compare models inside one program, but it does not cancel if you compare an R number with a Python number. Our guide to Python for statistical analysis covers the wider toolchain.

Where AIC gets used in real analyses

A few situations come up repeatedly in thesis and trial work:

  • Covariate selection in regression. Compare nested and non-nested candidate models fitted to one complete-case dataset. Use ΔAIC and weights, and give the reason for each candidate.
  • Mixed-effects models. AIC helps compare random-effects structures, but the likelihood used (maximum likelihood versus restricted maximum likelihood) must be the same across candidates, and fixed effects can be compared only under maximum likelihood. See our practical guide to mixed effects models and the comparison of fixed effects versus random effects.
  • Link functions and distributions. As in the coin-flip example, you can compare logit, complementary log-log and log-log links for a binary outcome, provided the response is identical.
  • Survival and time-to-event models. Parametric survival models fitted to the same follow-up data can be ranked the same way.

Reporting AIC so a reviewer can reproduce it

A reviewer who asks for method justification wants more than a table of numbers. A supervisor who cannot reproduce your figures wants the pipeline. Include:

  1. The candidate set, and why each model is in it. Models added after seeing the results are a form of data dredging.
  2. The dataset and exclusions, confirming every model used the same rows.
  3. The criterion and software, including AICc if used and the package version, since parameter counting differs by software.
  4. ΔAIC and Akaike weights, not raw AIC values.
  5. Absolute fit checks for the selected model, such as residual plots and predictive performance.
  6. The code, as a script or notebook, so the table can be regenerated.

Perspective

We built PlotStudio AI around a problem that AIC makes obvious: the number is the easy part. The hard part is everything around it. Which models were in the set, whether every fit used the same rows, which parameter count the software applied, and whether the winner was ever checked against residuals.

Traditional tools such as R, Python, Stata, SPSS, SAS and Jupyter give you the statistical computing, and they will stay in your toolkit. What a thesis timeline lacks is a layer that plans, executes, inspects and documents the whole comparison. That is what we mean by agentic analytics for researchers.

In PlotStudio AI, specialized agents plan the investigation, write and run real code, inspect intermediate results and synthesize the findings. Plan Mode lets you review and change the proposed methods, assumptions and steps before anything runs, which is the moment to decide whether the goal is prediction (AIC) or structure (BIC). Skills can encode your lab’s statistical conventions and reporting expectations, and completed work is kept as searchable Analysis Pages and exported as notebooks or PDF reports, so a supervisor can see how each number was produced.

Analyses can run locally on your machine, which matters when patient data cannot go to a cloud platform.

Aymen

Run your model comparison with PlotStudio AI

If your model selection has to survive a viva, a reviewer or a supervisor who wants to rerun it, PlotStudio AI gives you a reviewable plan, executed code and exportable notebooks and PDF reports in one workflow. Regression, ANOVA, mixed-effects models, survival analysis and Cox proportional hazards models are among the methods it is designed for, in Python and R.

The Bring Your Own Key plan is $399.90 per year on the academic page, or $39.99 per month on the pricing page, where Managed Credits ($69.99 per month) and a free trial are also listed.

Plotstudio

FAQ

What is a good AIC value?

There is no good absolute value. AIC is only meaningful relative to other models fitted to the same data, so look at ΔAIC. A model within about 2 units of the best has substantial support, and one more than 10 units behind has essentially none (Portet, 2020).

Can AIC be negative?

Yes. AIC is built from a log-likelihood, and for continuous outcomes the likelihood can exceed 1, which makes −2 ln(L̂) negative. A negative AIC is read the same way: the lower value is preferred, and only differences matter.

Is AIC a statistical test with a p-value?

No. Information criteria rank models by estimated information loss and are not null hypothesis tests, so results should not be described as significant or rejected (Turku PET Centre). Report ΔAIC or Akaike weights instead.

Should I use AIC or BIC?

Use AIC when the goal is prediction and BIC when you want the simplest adequate structure. BIC’s penalty of ln(n) per parameter exceeds AIC’s 2 once n is above about 8, so BIC selects smaller models. If you are unsure, decide the goal in advance and report both.

Sources