Which of the following could be used as a test for autocorrelation up to third order

In this article, we discuss how to test for autocorrelation in R. Especially in the context of regression models.

The non-existence of autocorrelation among residuals is one of the main assumptions of a regression model. If autocorrelation does exist, the outcomes of the model might be unreliable. Therefore, it’s essential to check this assumption.

In R, the easiest way to test for autocorrelation among residuals is with the ACF[] function. This function computes and plots the autocorrelation of a regression model and makes your analysis straightforward. Alternatively, you can perform the Durbin-Watson test or the Breusch-Godfrey test.

In this article, we show how to use the ACF[] function and perform both tests. We use examples and R code that you can use directly in your own project.

What is Autocorrelation?

Autocorrelation occurs when the residuals of a regression model are not independent of each other. In other words, if the value of residual ei depends on the value of residual ei-1.

Autocorrelation, or lagged correlation, can be measured in different forms, of which lag-1 is the most common. However, you also have lag-2, lag-3, etc.

  • Lag-1: Checks the correlation between ei and ei-1.
  • Lag-2: Checks the correlation between ei and ei-2.
  • Lag-3: Checks the correlation between ei and ei-3.
  • etc.

Autocorrelation occurs mainly in time series. For example, when we measure the height of the same person at different moments in time. The height of a person now is in general highly correlated with its height during the previous measurement. However, autocorrelation can also occur in other circumstances.

Autocorrelation leads to underestimation of the standard error of predictor variables. Which in turn makes you think that predictors are significant [when there are not]. Therefore, you should always check for the non-existence of autocorrelation in your regression model.

Do you know: 3 Ways to Check the Homoscedasticity assumption and 3 Ways to Check for Multicollinearity.

In the sections below we show 3 ways to test for autocorrelation in R. We cover the ACF plot, the Durbin-Watson test, and the Breusch-Godfrey test. For each method, we include two examples.

In the examples, we test the assumption of the non-existence of autocorrelation. However, the residuals of one regression model are highly correlated while the other model meets the assumption of no-autocorrelation. The difference in the outcome of both examples will help you to draw the right conclusion in your analysis.

The first model estimates the daily closing prices of the UK stock exchange [FTSE] based on the German stock exchange [DAX]. As you might expect, the closing price of a stock exchange is highly correlated with the closing price of the previous day. Therefore, the residuals might show autocorrelation.

The second model estimates the fuel efficiency [MPG] of a car based on the rear axle ratio [DRAT]. In this case, we won’t expect autocorrelation of the residuals.

1. Test for Autocorrelation with the ACF Plot

The first way to check for autocorrelation in R is by using the ACF[] function. This function is part of the stats package and computes and plots estimates of the autocorrelation.

The ACF[] function requires just one argument, namely a numeric vector with the residuals of the regression model. Additionally, you can use the type = “correlation”-parameter to specify what you want to calculate.

Syntax

acf[residuals, type="correlation"]

Example with Autocorrelation

library[stats]

model 

Bài Viết Liên Quan

Chủ Đề