Guest User

Untitled

a guest
Jul 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. library(forecast)
  2. data<-c(1,4,3,5,7,8,1,2,6,7,2,3,4,4);
  3. mymodel<-Arima(data[1:10], order=c(1,1,1)) # Fitting the model using data from 1 to 10
  4.  
  5. forecast(mymodel, h=1)$mean[1] # Forecasting point 11
  6. [1] 5.263669
  7.  
  8. fitted(Arima(data[1:11], model = mymodel))[11] # Applying the model estimated from 1 to 10 to data from 1 to 11 and taking fitted values
  9. [1] 5.125379
  10.  
  11. > mymodel
  12. Series: data[1:10]
  13. ARIMA(1,1,1)
  14.  
  15. Coefficients:
  16. ar1 ma1
  17. 0.3417 -0.9999
  18. s.e. 0.4143 0.7224
  19.  
  20. mymodel <- Arima(data[1:10], order=c(1,0,1))
  21. forecast(mymodel, h=1)$mean[1] # Forecasting point 11
  22. # 4.98265
  23. mymodel2 <- Arima(data[1:11], model = mymodel)
  24. fitted(mymodel2)[11]
  25. # 4.98265
Add Comment
Please, Sign In to add comment