# Forecast next time series in R predict value

Using R command predict, if the predict value is almost same, what can I do next step?

For example,

A time series model is determined as AR(1) model, and I predict the next value but it's very suspicious. (Data's period=12 and predict period=12 month, 1 year)

Example data is below.

Is that means only first few data available? And I can forecast just next few time period?

2459853
2481777
2496666
2506778
2513645
2518309
2521476
2523627
2525088
2526080
2526754
2527211


EDIT:

First of all, I thinks there is some misunderstanding about example data.

Below is original data and first data was predicted value.(forecasted by AR(1) model)

Now My question is same as first. Thanks.

2935833 2622529 2719635 2625179 2311187 2101758 2552638 2883423 3128904 2959348 2759000 2233755 2560858 2548821 2625675 2326076 1662956 1772409 1797275 2639852 2799990 3133285 2438296 2583766 2610157 2493415 2094163 2174301 2283420 2505128 2873785 2339727 2985829 3037351 1828265 1038562 1474727 1523331 2122667 2571006 2252161 2422347 2155973 2294976 2809652 2436293 2561852 2199544 2674423 2551363 3110508 3177925 3046952 2850904 3002830 2910913 2809172 3136842 3355368 3604565 3013310 3125751 2548605 2646575 2231458 1962095 1958019 2143073 2305966 2620302 2356447 2427571

-
 I can reproduce these data exactly, assuming they are rounded to the nearest integer. The formula is $y = 2528180 - \exp(11.519 -0.386936x)$, $x=1,2,\ldots,12$. This formula forecasts the next value as $2527522$. – whuber♦ Dec 5 '11 at 14:30

Here is the plot of your data:

It is clear then, that it is probably not generated by statistical model. It is then not surprising that AR(1) predictions look suspicious. I suspect that some S-curve type function can be perfectly fitted to your data.

Update

Note What comes below is complement to IrishStat answer with R code illustrations.

On the other hand, as IrishStat pointed out, AR(1) model is useful here. In fact we have the following:

> bb<- structure(list(V1 = c(2459853L, 2481777L, 2496666L, 2506778L,
2513645L, 2518309L, 2521476L, 2523627L, 2525088L, 2526080L, 2526754L,
2527211L), index = 1:12, lV1 = c(NA, 2459853L, 2481777L, 2496666L,
2506778L, 2513645L, 2518309L, 2521476L, 2523627L, 2525088L, 2526080L,
2526754L)), .Names = c("V1", "index", "lV1"), row.names = c(NA,
-12L), class = "data.frame")

> summary(lm(V1~lV1,data=bb))

Call:
lm(formula = V1 ~ lV1, data = bb)

Residuals:
Min       1Q   Median       3Q      Max
-0.44873 -0.16852  0.00065  0.20665  0.28504

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.112e+05  9.046e+00   89681   <2e-16 ***
lV1         6.791e-01  3.605e-06  188386   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.246 on 9 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared:     1,  Adjusted R-squared:     1
F-statistic: 3.549e+10 on 1 and 9 DF,  p-value: < 2.2e-16


So we have a perfect fit (in the precision of original data):

> fitted(lm(V1~lV1,data=bb))-bb$V1[-1] 2 3 4 5 6 -0.0431514978 0.2081317329 -0.2217918197 0.1431496162 -0.2695231647 7 8 9 10 11 0.1938952347 -0.0006489181 -0.1915123449 0.0177617292 -0.2850446492 12 0.4487340818  The forecast for future values is : $$Y_{t+h}=\alpha(1+\rho+...+\rho^{h-1})+\rho^hY_t$$ where$Y_t$is the last point of the data,$h$-- the forecasting horizon, and$\alpha$and$\rho$are estimated coefficients: > coef(lm(V1~lV1,data=bb)) (Intercept) lV1 8.112164e+05 6.791302e-01  Since your data is without stochastic error, the usual methods might behave strangely, which is illustrated by the following code: > auto.arima(ts(bb$V1))
Series: ts(bb$V1) ARIMA(2,2,1) Coefficients: ar1 ar2 ma1 1.9691 -0.9691 0.8809 s.e. NaN NaN NaN sigma^2 estimated as 37898: log likelihood=-70.44 AIC=148.88 AICc=156.88 BIC=150.09  Or even > arima(ts(bb$V1),order=c(1,0,0))
Series: ts(bb$V1) ARIMA(1,0,0) with non-zero mean Coefficients: ar1 intercept 0.9569 2497162.58 s.e. 0.0575 27950.09 sigma^2 estimated as 80110030: log likelihood=-127.46 AIC=260.92 AICc=263.92 BIC=262.37  As you see the AR(1) coefficient is estimated incorrectly. The fit is also very bad compared to OLS fit: > ts(bb$V1)-fitted(arima(ts(bb$V1),order=c(1,0,0))) Time Series: Start = 1 End = 12 Frequency = 1 [1] -10830.884 20317.315 14226.441 10090.616 7281.075 5373.793 [7] 4077.641 3198.024 2600.654 2194.570 1919.289 1731.313  The precise explanation why is that can be complicated, but the general rule is, that algorithms might perform poorly on corner cases (zero errors in this case). - (+1) Step 1: Plot your data. – cardinal Dec 5 '11 at 13:36 Re the edits: note that this AR(1) model is identical to the fit I reported, because the lV1 coefficient of 6.7913E-01 equals$\exp(-0.386936)\$ (the rate coefficient in my fit). Whether one should view the data as autoregressive or as following an exponential really depends on how the data are generated and the purpose of the predictions. – whuber Dec 5 '11 at 15:20

Your data can be modelled with an AR(1) which can flexibly approximate many different kinds of time series data. All models are wrong some are useful said Prof. Box. The model

     MODEL COMPONENT          LAG    COEFF     STANDARD      P       T

#                          (BOP)              ERROR      VALUE   VALUE

1CONSTANT                          .811E+06     8.18       .0000  9999.99

2Autoregressive-Factor #  1    1   .679         .100       .0000     6.79


FINAL REPORT

MODEL STATISTICS AND EQUATION FOR THE CURRENT EQUATION (DETAILS FOLLOW).

Estimation/Diagnostic Checking for Variable Y se

Number of Residuals (R) =n 11

Number of Degrees of Freedom =n-m 9

Residual Mean =Sum R / n .000000

Sum of Squares =Sum R**2 .544708

Variance =SOS/(n) .453923E-01

Standard Deviation RMSE =SQRT(Adj Var) .246014

Standard Error of the Mean =Standard Dev/ (n-m) .820048E-01

Mean / its Standard Error =Mean/SEM .000000

Mean Absolute Deviation =Sum(ABS(R))/n .183942

AIC Value ( Uses var ) =nln +2m -30.0165

SBC Value ( Uses var ) =nln +m*lnn -29.2207

BIC Value ( Uses var ) =see Wei p153 207.690

R Square = 1.00000

The graph of the actual/fit and forecasts is . The plot of the residuals from this model suggest a non-random error term leading to some augmentation as does the ACF of the errors . I would think that some slight augmentation might be needed to approximate what to me is a clearly determinstic series . Note that the forecast 'is similar" to the last value thus having approached an assymptotic value which is a characteristic of all non-differenced AR models. The forecasts are presented here . Here is the ACF of the model errors

The simplicity of an auto-regressive model can be seen when it is expressed as a simple ols model.

MODEL EXPRESSED AS AN XARMAX

Y[t] = a1Y[t-1] + ... + a[p]Y[t-p]

   + w[0]X[t-0] + ... + w[r]X[t-r]

+ b[1]a[t-1] + ... + b[q]a[t-q]

+ constant


THE RIGHT-HAND SIDE CONSTANT IS: 811220.

Y 1 .679130 * Y( 12 )= 2527211.000000= 1716305.403967

                                           NET PREDICTION FOR Y(   13 )= 2527521.811269

-
 +1, for noticing that this is AR(1) with zero error. Did your software detected that automatically, or did you ask to fit the AR(1) regression? – mpiktas Dec 5 '11 at 14:58 :mpiktas When I ran it automatically it suggested a double difference with an AR(1) and a constant. This augmented model gave very similar forecasts and might have been a "slight overkill" with just 12 data points. It did however suggest to me that the residuals from a simple AR(1) might have structure and indeed they do. – IrishStat Dec 5 '11 at 16:46 :mpkitas One of your models ARIMA(2,2,1) ar1 ar2 ma1 1.9691 -0.9691 0.8809 can be algebraically simplified as follow (1-2B +1B**2)/(1-B) to (1-B) or (1-phiB) . What you received as a solution had redundant structure i.e. cancelling structure. – IrishStat Dec 5 '11 at 17:03 :mpkitas To be clear 1.9691 approx = 2.0 ; -.9691 approx = -1.0 ; .8809 approx = 1.0 . The problem with AIC criteria optimzation is that if the true model = mean + a(t) this can be confused with an arima model (1,0,1) where phi=.8 and ma1=.8 . In your case you received an AR(2) and an MA(1) while an AR(1) would have sufficed. – IrishStat Dec 5 '11 at 20:20

Now that your question has been rephrased, we have . We proceed to automatically identify ( this step is possible with a lot of programs ) the underylying model using which leads to . This model generates a set of residuals . These residuals visually have a clear lack of normality as a there are pulses and two level shifts (clumps or residuals) near the end. The ACF of these residuals is downward biased by the abnormal values and thus can be classified as an "alice in wonderland test". . We can now look to identify simultaneously bot the ARIMA structure and any Intervention Variables that might need to be incorporated to provide a robust estimate of the ARIMA coefficients.. The equation for this model is . Note that the two level shifts are at period 49 and 64 with one time unusual points at 35,36,37,38 { a patch of pulses} and 60. Recall that there are 72 values in the history of the series. Note that the robustly estimated AR(1) coefficient is .400 versus the .681 from the simple original model. Note that the "two clusters of similar values" that were identified incorrectly enhanced i.e. made larger the AR(1) coefficient since the values in each of the two clusters are very predictable lag 1. A plot of the residuals from this augmented model is shown with an ACF of . Now with respect to the forecasts from this complete model. They are based upon the level shifts, the seasonal pulse and the AR(1) coefficient. As can be seen the forecasts reach a limiting value within a few periods.

-