1、交通流三大参数 见链接地址
2、R语言建立SARIMA模型,代码如下:
library(readxl)
data<-read_excel("E:/HL/HIVdata.xlsx",col_names = TRUE)
View(data)
#将数据生成时间序列#
data_ts<-ts(data$Incidence_rate,frequency = 12,start = c(2004,1))
#建立ARIMA模型#
library(forecast)
library(tseries)
tsdisplay(data_ts)
#取2004-2014数据作为训练集#
datatest<-ts(as.vector(data$Incidence_rate[1:132]),start = c(2004,1),frequency = 12)
tsdisplay(datatest)
#差分平稳化#
s1<-diff(datatest)
plot(s1)
adf.test(s1)
acf(s1)
pacf(s1)
#首先用auto.arima来预测#
fit<-auto.arima(datatest)
#模型1拟合#
fit1<-arima(datatest,order = c(0,1,1),seasonal =list(order=c(1,0,1),period=12))
#模型评价#
qqnorm(fit1$residuals)
qqline(fit1$residuals)
Box.test(fit1$residuals,type="Ljung-Box")
#预测12个月的值#
f.p1<-forecast(fit1,h=12,level=c(99.5))
plot(f.p1)
lines(f.p1$fitted,col="green")
lines(data_ts,col="red")
#模型2拟合#
fit2<-arima(datatest,order = c(3,1,1),seasonal = list(order=c(1,1,1),perid=12))
fit2
f.p2<-forecast(fit2,h=12,level=c(99.5))
plot(f.p2)
lines(f.p2$fitted,col="green")
lines(data_ts,col="red")