# Serial Correlation ### Compute Sample ACF and PACF

This example shows how to compute the sample autocorrelation function (ACF) and partial autocorrelation function (PACF) to qualitatively assess autocorrelation.

• Serial correlation or autocorrelation is usually only defined for weakly stationary processes, and it says there is nonzero correlation between variables at different time points. Heteroskedasticity means not all of the random variables have the same variance. Note that if you talk about one, you cannot talk about the other: if a series is heteroskedastic, then it cannot be weakly.
• Testing for Serial Correlation The above discussion suggests a very simple strategy for testing for serial correlation: check the magnitude and significance level of your estimated. Economists that deal with time-series data often prefer the sophisticated-yet-unintuitive.

The time series is 57 consecutive days of overshorts from a gasoline tank in Colorado.

The sample ACF and PACF exhibit significant autocorrelation. The sample ACF has significant autocorrelation at lag 1. The sample PACF has significant autocorrelation at lags 1, 3, and 4.

Vscode-theia-comparator. Step 1. Load the data.

Load the time series of overshorts.

## Testing For Serial Correlation In R

The series appears to be stationary.

Step 2. Plot the sample ACF and PACF.

## Serial Correlation Is The Same As

Plot the sample autocorrelation function (ACF) and partial autocorrelation function (PACF).

The sample ACF and PACF exhibit significant autocorrelation. The sample ACF has significant autocorrelation at lag 1. The sample PACF has significant autocorrelation at lags 1, 3, and 4.

## Negative Serial Correlation Emh

The distinct cutoff of the ACF combined with the more gradual decay of the PACF suggests an MA(1) model might be appropriate for this data.

Step 3. Store the sample ACF and PACF values.

Store the sample ACF and PACF values up to lag 15.

## Serial Correlation Econometrics

The outputs `acf` and `pacf` are vectors storing the sample autocorrelation and partial autocorrelation at lags 0, 1,..,15 (a total of 16 lags).