Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# aicbic

Akaike or Bayesian information criteria

## Syntax

• aic = aicbic(logL,numParam) example
• [aic,bic] = aicbic(logL,numParam,numObs) example

## Description

example

aic = aicbic(logL,numParam) returns Akaike information criteria (AIC) corresponding to optimized loglikelihood function values (logL), as returned by estimate, and the model parameters, numParam.

example

[aic,bic] = aicbic(logL,numParam,numObs) additionally returns Bayesian information criteria (BIC) corresponding to logL, numParam, and the sample sizes associated with each logL value.

## Examples

expand all

### Compare AIC Statistics

Calculate and interpret the AIC for four models.

The loglikelihood function values (logL) and the number of model parameters (numParam) from four multivariate time series analyses are:

```logL1 = -681.4724;
logL2 = -632.3158;
logL3 = -663.4615;
logL4 = -605.9439;

numParam1 = 12;
numParam2 = 27;
numParam3 = 18;
numParam4 = 45;
```

Calculate the AIC.

```aic = aicbic([logL1,logL2,logL3,logL4], ...
[numParam1,numParam2,numParam3,numParam4])
```
```aic =

1.0e+03 *

1.3869    1.3186    1.3629    1.3019
```

The model with the lowest AIC has the best fit. Therefore, the fourth model fits best.

### Information Criteria Statistics for Simulated Data

Compare information criteria statistics for several model fits.

Specify the model

where εt is Gaussian with mean 0 and variance 2. Simulate data from this model.

```rng(1);  % For random data reproducibility
T = 100; % Sample size
DGP = arima('Constant',-4,'AR',[0.2, 0.5], ...
'Variance',2);
y = simulate(DGP,T); ```

Define three competing models to fit to the data.

```EstMdl1 = arima('ARLags',1);
EstMdl2 = arima('ARLags',1:2);
EstMdl3 = arima('ARLags',1:3);```

Fit the models to the data.

```logL = zeros(3,1); % Preallocate loglikelihood vector
[~,~,logL(1)] = estimate(EstMdl1,y,'print',false);
[~,~,logL(2)] = estimate(EstMdl2,y,'print',false);
[~,~,logL(3)] = estimate(EstMdl3,y,'print',false);```

Compute the AIC and BIC for each model.

`[aic,bic] = aicbic(logL, [3; 4; 5], T*ones(3,1))`
```aic =

381.7732
358.2422
358.8479

bic =

389.5887
368.6629
371.8737```

The model containing two autoregressive lag parameters fits best since it yields the lowest information criteria. The structure of the best fitting model matches the model structure that simulated the data.

## Input Arguments

expand all

### logL — Optimized loglikelihood valuesscalar | vector

Optimized loglikelihood objective function values associated with various model fits, specified as a scalar or vector.

Obtain an optimized loglikelihood value using estimate, infer, vgxvarx, or an Optimization Toolbox™ function such as fmincon or fminunc.

Data Types: double | single

### numParam — Number of estimated parametersscalar | vector

Number of estimated parameters associated with each corresponding fitted model in logL, specified as a positive integer, or a vector of positive integers having the same length as logL.

If numParam is a scalar, then aicbic applies it to all logL values.

For univariate time series models, use length(info.X) to obtain numParam from a fitted model returned by estimate.

For multivariate time series models, obtain numParam using vgxcount from a vgxset or vgxvarx model specification.

Data Types: double | single

### numObs — Sample sizesscalar | vector

Sample sizes of the observed series associated with each corresponding fitted model in logL, specified as a positive integer, or a vector of positive integers having the same length as logL.

aicbic requires numObs to compute the BIC.

If numObs is a scalar, then aicbic applies it to all logL values.

Data Types: double | single

## Output Arguments

expand all

### aic — AIC statisticsscalar | vector

AIC statistics associated with each corresponding fitted model in logL, returned as a vector with the same length as logL.

### bic — BIC statisticsscalar | vector

BIC statistics associated with each corresponding fitted model in logL, returned as a vector with the same length as logL.

expand all

### Akaike Information Criterion

A model fit statistic considers goodness-of-fit and parsimony. Select models that minimize AIC.

When comparing multiple model fits, additional model parameters often yield larger, optimized loglikelihood values. Unlike the optimized loglikelihood value, AIC penalizes for more complex models, i.e., models with additional parameters.

The formula for AIC, which provides insight into its relationship to the optimized loglikelihood and its penalty for complexity, is:

### Bayesian Information Criterion

A model fit statistic considers goodness-of-fit and parsimony. Select models that minimize BIC.

Like AIC, BIC uses the optimal loglikelihood function value and penalizes for more complex models, i.e., models with additional parameters. The penalty of BIC is a function of the sample size, and so is typically more severe than that of AIC.

The formula for BIC is:

## References

[1] Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.