数据还有很多没弄好,程序还没弄完全好。
> read.xlsx("H:/ProjectPaper/论文/1.xlsx","Sheet1")
> item<- read.xlsx("H:/ProjectPaper/论文/1.xlsx","Sheet1")
> item<- ts(item,start=c(2014))
> plot.ts(item)
> itemdiff<- diff(item,differences=1)
> plot.ts(itemdiff)
> itemdiff2<- diff(item,differences=2)
> plot.ts(itemdiff2)
> itemdiff3<- diff(item,differences=3)
> plot.ts(itemdiff3)
> acf(itemdiff2,lag.max=20)
> acf(itemdiff2,lag.max=20,plot=FALSE)
Autocorrelations of series ‘itemdiff2’, by lag
0 1 2 3 4 5 6 7
1.000 -0.668 0.177 0.004 -0.111 0.255 -0.289 0.275
8 9 10 11 12 13 14
-0.282 0.204 -0.016 -0.191 0.281 -0.197 0.058
> pacf(itemdiff2,lag.max=20)
> pacf(itemdiff2,lag.max=20,plot=FALSE)
Partial autocorrelations of series ‘itemdiff2’, by lag
1 2 3 4 5 6 7 8 9
-0.668 -0.484 -0.339 -0.499 -0.208 -0.297 0.061 -0.068 0.011
10 11 12 13 14
0.140 -0.142 -0.169 -0.033 -0.148
> itemarima<-arima(item,order=c(1,2,1))
> itemarima
Call:
arima(x = item, order = c(1, 2, 1))
Coefficients:
ar1 ma1
-0.4631 -1.0000
s.e. 0.2145 0.2463
sigma^2 estimated as 602016: log likelihood = -122.96, aic = 251.92
> library(forecast)
> itemarimaforecast<-forecast(itemarima,h=5,level=c(99.5))
> itemarimaforecast
Point Forecast Lo 99.5 Hi 99.5
2031 5777.286 3529.572 8025.001
2032 5780.032 3164.663 8395.400
2033 5818.222 2592.498 9043.945
2034 5839.998 2169.228 9510.768
2035 5869.375 1721.669 10017.081
> plot.forecast(itemarimaforecast$residuals)
Error in plot.forecast(itemarimaforecast$residuals) :
没有"plot.forecast"这个函数
> acf(itemarimaforecast$residuals,lag.max=20)
> Box.test(itemarimaforecast$residuals, lag=20, type="Ljung-Box")
Box-Ljung test
data: itemarimaforecast$residuals
X-squared = NA, df = 20, p-value = NA
> plot.ts(itemarimaforecast$residuals)