1
$\begingroup$

I am a newbie when it comes to R and I do not have a strong math background. That being said, my goal is to automate forecasting time series. I went to Google and found several good articles about forecasting by hand.

ARIMA article

R Time Series

The information in my time series is collected every 15 minutes. Therefore, I made my time series in R look like the following:

library(tseries)
input <- c(59.1,47.3,51.9,61.8, 63.6, 76.7,78.1,80.1)
ts <- ts(input, frequency=15)

From there I performed the Dickey-Fuller test by running the following code:

testResults <- adf.test(ts)
testResults

RESULTS Dickey-Fuller = -2.3504 Lag order = 1 p-value = 0.4389 alternative hypothesis: stationary

Question1: I have read several other posts and I believe that I need to look at the p-value to determine if my time series is stationary or not. Is that correct? If so, is there a certain value that would apply to all time series or does it vary from one to another? Another words, if the p-value is 0.05 or higher, then we need to remove trending and/or seasonality. What is that value?

Question2: Is it acceptable to run ndiffs on my time series instead of running the Dickey-Fuller test?

Question3 Once the differencing is completed, is there a need to perform stl() or decompose()?

After this part, I believe that it is time to start to fit the model. However, I see some folks running acf and pacf.

Question4 I see that these methods are used for checking residuals outside the insignificant zone. Does this mean if I do not have more than 1 plot outside the insignificant zone, that I can not predict future values? Are any of the values calculated here used in future calculations of the model?

Question5 If I use the auto.arima method for fitting a model to my data, can I just get away with removing trending and seasonality?

Thank you in advance.

$\endgroup$
  • 1
    $\begingroup$ Not an answer, but research.fb.com/prophet-forecasting-at-scale may be interesting and effective for you. $\endgroup$ – Gijs Oct 17 '17 at 15:42
  • 1
    $\begingroup$ Careful: frequency=15 means that your data may have a seasonal cycle every 15 data points, i.e., with a period of 15*15 = 225 minutes, or 3 hours and 45 minutes. That is almost certainly not what you want. If you suspect an hourly cycle, use frequency=4. If you suspect a daily cycle, use frequency=96. If you suspect multiple-seasonalities, look at that tag and consider a tbats model. $\endgroup$ – Stephan Kolassa Oct 17 '17 at 16:01
  • $\begingroup$ I recommend Forecasting: Principles and Practice by Hyndman and Athanasopoulos, a free online forecasting textbook. To your question 5: if you have a single seasonality and correctly set frequency as per my previous comment, then auto.arima() should already take care of all trends and seasonalities automagically. Try it. $\endgroup$ – Stephan Kolassa Oct 17 '17 at 16:07
2
$\begingroup$

Respectable members have given you good hints. I will try fill in the points not yet touched.

Question1: What is that value?

It is a basic statistical concept. You ought to specify alpha before running into hypothesis testing. If you plan to run several statistical tests, it is better to take care of adjusting alpha to the number of the tests. 0.05 / 0.01 / 0.001 are not necessarily valid values. You should decide which Type 1 Error chance you accept.

Question2: Is it acceptable to run ndiffs

Yes. You may need to difference your master timeseries at least once. Second order differencing is not so common but still can be needed. Besides you could check out the opportunity to take diff(log(X)). This can be needed if the volatility of your master data is non constant.

Question3 Once the differencing is completed, is there a need to perform stl() or decompose()?

To the best of my understanding you stationarize (in a weak sense) your series by either removing trend and possibly taking log(residual X) OR by taking an appropriate order of differencing. Strongly, you are about to check for AR coefficient to be constant. Then you should see the autocorrelation structure in your data either by taking acf(), pacf(), or checking out the seasonal component resulted from the seasonal decomposition.

Question4 I see that these methods are used for checking residuals outside the insignificant zone.

You are supposed to take a closer look at the residuals of the final nested model (ar, differenced, possibly moving averaged). The residuals should not show any autoregressive components in acf(), pacf() and they should also be about zero in mean and, ideally, should have a Gaussian distribution.

$\endgroup$
  • $\begingroup$ I prefer to follow data differencing course since I loose neither cyclical component (pacf profile) no trend (bias in differenced values). It seems easier to me to work with stationary data containing time-lagged dependencies. $\endgroup$ – Alexey Burnakov Oct 17 '17 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.