**Have a Question?**

**Phone:** +1 (888) 427-9486

+1 (312) 257-3777

Contact Us

# For goodness of fit's sake

Attachment | Size | |
---|---|---|

How_Does_It_Fit.pdf | ||

LA ozone.xlsx |

No, this is not a recap from the O.J. Simpson trial, but it is a question we face whenever we propose a model for our data: does the model fit and does it explain the data variation properly?

In a time series modeling process, we seek a quantitative measure of the discrepancy (or the goodness of fit) between the observed values and the values expected under the model in question. The discrepancy measure is crucial for two important applications: (1) finding the optimal values of the model’s parameters, and (2) comparing competing models in an attempt to nail the best one. We believe that the model with the best fit should give us superior predictions for future values.

A few questions might spring to mind: What are the goodness-of-fit functions? How are they different from each other? Which one should I use? How are they related to the normality test?

In this tutorial, we’ll discuss the different goodness-of-fit functions through an example of the monthly average of ozone levels in Los Angeles between 1955 and 1972. This data set was used by Box, Jenkins, and Riesel in their time series text book – Time Series Forecast and Control, published in 1976.

## Background

In this tutorial, we’ll start with the likelihood function, and then cover derivative measures (e.g. AIC, BIC, HQC, etc.)

The likelihood function is defined as a function of the model parameters of the statistical model. The likelihood of a set of parameter values given some observed outcomes is equal to the probability of those observed outcomes given those parameter values .

Where

- probability mass (density) function

Assuming {} consists of independent and identically distributed (i.i.d) observations, the likelihood function of a sample set is expressed as follows:

To overcome the diminishing value of as the sample size increases and to simplify its calculation, we take the natural logarithm of the likelihood function.

## Example 1: Gaussian distribution

Where

- the un-biased estimate of the standard deviation
- the distribution standard deviation
- the sample data mean or average

**Note:**The log-likelihood function is linearly related to the sample data variance; as the sample data variance increases (fit is worse), the log-likelihood decreases, and vice versa.

## Models comparison

Typically, we use the LLF in searching for the optimal values of the coefficients of a model using one sample data set.

To compare the goodness of fit between models, we encounter two main challenges:

- The number of free parameters in each model is different. Using LLF as it stands now, it is possible the LLF will give greater weight to complex models, as they can (theoretically) over-fit the sample data.
- Due to the different lag orders in each model, the number of remaining non-missing observations can differ between models, assuming we use the same sample data with all models.

We use two distinct measures to address these issues:

## Akaike’s Information Criterion (AIC)

The original definition (AIC) adds a linear penalty term for the number of free parameters, but the AICc adds a second term to factor in to the sample size, making it more suitable for smaller sample sizes.

## Bayesian (Schwarz) Information Criterion (BIC/SIC or SBC)

As in AIC, the BIC penalizes the model complexity . Given any two estimated models, the model with the lower value of BIC is preferred.

The BIC generally penalizes free parameters more strongly than does the AIC, though it depends on the size of n and the relative magnitude of n and k.

## Ozone levels in downtown Los Angeles

In this tutorial, we’ll use the monthly average of the hourly ozone levels in LA between Jan 1955 and Dec 1972.

The underlying process exhibits seasonality around a 12-month period, but it appears to decay over time. There are two important facts to consider about this example:

- In 1960, two major events occurred, which might have reduced ozone levels: (1)the Golden State Freeway was opened, and (2) a new rule (rule 63) was passed to reduce the allowable proportion of hydrocarbons in locally-sold gasoline.
- In 1966, regulation was adopted requiring engine design changes that were expected to reduce the production of ozone in new cars.

The underlying process had undergone major changes throughout the sample data period. For forecasting purposes, we will exclude the observations between 1955 and 1966. For this tutorial, we assume we did not know about those events and simply ignore them.

The summary statistics suggest the following: (1) serial correlation, (2) arch effect, and (3) significant skew.

Next, let’s examine the ACF and PACF plot (correlogram).

The correlogram (ACF and PACF) appears similar to an Airline type of model with a 12-month period of seasonality. We went ahead and constructed the model, then calibrated its parameter values using the sample data.

**Note:** The calibration process is a simple **maximization** problem with the LLF as the utility function, and the model’s validity function as the only constraint. We can also use AIC or BIC as the utility function instead of the LLF, but we have to search for parameter values that **minimize** the utility.

Let’s now compute the standardized residuals and determine the different goodness-of-fit measures: LLF, AIC and BIC.

## 1. Compute the residuals

**Hard way:**Using the AIRLINE_MEAN function, get the estimated model’s values and subtract those from the observed values to get the raw residuals. Subtract the residuals’ mean from the raw residuals and divide by standard deviation to get the standardized residuals.- Easy way: Using the AIRLINE_RESID function will yield an array of the standardized residuals of the model.

Let’s plot the distribution (and QQ-Plot) of the standardized residuals.

## 2. Compute the log-likelihood for the standardized residuals

Now, let’s compute the log-likelihood function. We can do that either by computing the log of the mass function at each point and then adding them together, or simply by using this formula:

**Note: **

- The number of non-missing points is 203 (i.e. 216 – 13). We have lost 13 points.
- LLF is not identical to the one we had earlier (LLF = -265) in the Airline model table. The AIRLINE_LLF uses Whittle’s approximation to compute the LLF function, which is relatively close and efficient for large sample data.
- The AIC and BIC values are relatively close, but the BIC penalizes more than AIC.

## Conclusion

The log likelihood function offers an intuitive way to think about a model’s fit with a sample data set, but it lacks any consideration for the model’s complexity or sample size. Thus, it is not appropriate for comparing models of different orders.

The Akaike and Bayesian information criteria fill the gap that LLF leaves when it comes to comparing models. They both offer penalty terms for the number of free parameters and the number of non-missing observations. Furthermore, in practice, the BIC is more often used than the AIC, especially in model identification and selection processes.

To compare models, **please note** that we need to use the same sample data with all models. We can’t use AIC or BIC to compare two models, each computed using a different data set.

## Tutorial Video

Attachment | Size |
---|---|

How_Does_It_Fit.pdf | 965.65 KB |

LA ozone.xlsx | 96.56 KB |