[R] Fitted values from AR model

bogus christofer bogu@@chr|@to|er @end|ng |rom gm@||@com
Thu Aug 11 16:50:09 CEST 2022


Hi,

I have below AR model and fitted values from the forecast package

library(forecast)
dta = c(5.0, 11, 16, 23, 36, 58, 29, 20, 10, 8, 3, 0, 0, 2, 11, 27, 47, 63,
60, 39)
fit <- arima(dta, order=c(2,0,0))
fitted(fit)

This gives fitted values as

Time Series:
Start = 1
End = 20
Frequency = 1
 [1] 13.461017  9.073427 18.022166 20.689420 26.352282 38.165635 57.502926
9.812106 15.335303  8.298995 11.543320  6.606999  5.800820  7.502621
9.930962 19.723966 34.045298 49.252447 57.333846 44.615067


However when I compare this result with Python, I see significant
difference particularly in the first few values as below

from statsmodels.tsa.arima.model import ARIMA
dta = [5.0, 11, 16, 23, 36, 58, 29, 20, 10, 8, 3, 0, 0, 2, 11, 27, 47, 63,
60, 39]
fit = ARIMA(dta, order=(2, 0, 0)).fit()
fit.predict()

array([21.24816788, 8.66048306, 18.02197059, 20.68931006,
26.35225759,38.16574655, 57.503278 , 9.81253693, 15.33539514,
8.29894655,11.54316056, 6.60679489, 5.80055038, 7.50232004,
9.93067155,19.72374025, 34.04524337, 49.25265365, 57.3343347 , 44.6157026 ])

Any idea why there are such difference between R and Python results will be
very helpful.

Thanks,

	[[alternative HTML version deleted]]



More information about the R-help mailing list