Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Augmented Dickey Fuller test for Time series with NA in r

Tags:

r

na

time-series

Does anyone have any suggestions to implement the augmented dickey fuller test in r on a time series with NA values?

The adf.test function does not accept NA values.

Any help is appreciated!

like image 871
TYL Avatar asked Oct 15 '22 15:10

TYL


1 Answers

Another r command would be ur.df (urca package).

But your problem is not related to coding. You cant use the ADF or any other stationary test on your time series. The test uses the lag structure and can therefore not be used. Have a look here to show how you could modify your data for the test and how this affects your test power.

1. "Close up" the gaps in the series. To consider a very simple example, suppose that we have data for y1, y2,....., yj-1, yj+1,...., yT (with yj missing). Then shift the (j+1)th observation back to the jth position, the (j+2)th observation back to the (j+1)th position, etc. The resulting series will then run "continuously" for (T-1) observations.

2. Replace the missing observation(s) with the last recorded observation before the gap. For the example above, the series will then have T observations: y1, y2,....., yj-1, yj-1, yj+1,......., yT.

3. Fill in a gap by linearly interpolating between the last recorded recorded observation before the gap, and the first recorded observation after the gap. For the example above, the series will then have T observations: y1, y2,....., yj-1, yj*, yj+1,......., yT . Here, yj* = yj-1 + (yj+1 - yj-1) / 2.

Ryan, Giles 1998

like image 199
Martin Avatar answered Oct 20 '22 14:10

Martin