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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With