Search code examples
rtime-seriesarimaforecast

arima function summary returns In training accuracy(object, test, d, D) : test elements must be within sample


I used arima function for quarterly time series and get this warning. (It worked in the beginning pretty well but then I don't know what problem caused this)

final is a dataframe with Value column consisting of numeric.

ar1 = arima(final$Value,order=c(1,0,0))
summary(ar1)

Call: arima(x = final$Value, order = c(1, 0, 0))

Coefficients: ar1 intercept 0.9879 7.3593 s.e. 0.0118 0.5308

sigma^2 estimated as 0.01265: log likelihood = 108.45, aic = -212.89

Training set error measures: ME RMSE MAE MPE MAPE Training set NaN NaN NaN NaN NaN Warning message: In trainingaccuracy(object, test, d, D) : test elements must be within sample

This happens to every arima function I tried modelling. With this results I tried forecast function and I get:

autoplot(forecast(ar1))

Error in ts(x) : 'ts' object must have one or more observations

I think something is wrong with my series but I don't understand what's wrong and why it did work fine initially.

Here is the series I used:

6.402755 6.447487 6.440739 6.444629 6.325880 6.213987 6.320138 6.221430 6.113566 6.131823 6.198132 6.280816 6.376518 6.682233 6.860274 6.969989 7.313399 7.299082 7.200292 6.975704 6.987592 7.093687 7.008988 6.878341 6.921279 6.885113 6.669485 6.646369 6.672451 6.683375 6.862668 6.971302 7.066513 6.982558 7.000745 6.947200 6.904141 6.907989 6.931114 6.840149 6.959360 7.010516 6.945923 6.997652 7.089783 7.128890 7.243348 7.185718 7.219598 7.340743 7.195484 7.007752 7.032095 7.112150 7.088555 7.044311 7.022457 7.034391 7.050923 7.005283 7.043774 7.097419 7.081782 6.989133 7.088950 7.173351 7.040893 6.990646 7.051991 7.142320 7.203468 7.277060 7.474889 7.554938 7.605872 7.711254 7.856296 7.919240 8.079298 8.137185 8.287493 8.272564 8.222417 8.325414 8.409447 8.473709 8.440126 8.427812 8.264590 8.335643 8.153812 7.567009 7.389719 7.591073 7.760976 7.851489 7.842401 7.827830 7.800251 7.911325 7.966901 7.934157 7.743143 7.539573 7.661231 7.593415 7.621503 7.713353 7.802358 7.778535 7.790057 7.850082 7.857232 7.826338 7.751009 7.687094 7.764962 7.853477 7.773990 7.785429 7.685640 7.709135 7.727118 7.827995 7.921841 8.023987 8.078377 8.120489 8.159005 8.131687 8.108646 8.037131 8.001428 8.024686 7.994422 8.048138 7.937257 7.696907 7.710174 7.787749 8.016172 8.121493 8.176831 8.238139


Solution

  • You are clearly using the forecast package already. So use Arima from the forecast package, not arima from the stats package.