2007年04月01日

LINK

経済情報処理Ⅲ
01組
02組



Posted by okh at 00:00│Comments(1)
この記事へのコメント
R-onlineのサンプルコード

# Level of Lake Huron 1875-1972
x <- ts(c(580.38, 581.86, 580.97, 580.8, 579.79, 580.39, 580.42,580.82, 581.4, 581.32, 581.44, 581.68, 581.17, 580.53, 580.01, 579.91, 579.14, 579.16, 579.55, 579.67, 578.44, 578.24, 579.1, 579.09, 579.35, 578.82, 579.32, 579.01, 579, 579.8, 579.83, 579.72, 579.89, 580.01, 579.37, 578.69, 578.19, 578.67, 579.55, 578.92, 578.09, 579.37, 580.13, 580.14, 579.51, 579.24, 578.66, 578.86, 578.05, 577.79, 576.75, 576.75, 577.82, 578.64, 580.58, 579.48, 577.38, 576.9, 576.94, 576.24, 576.84, 576.85, 576.9, 577.79, 578.18, 577.51, 577.23, 578.42, 579.61, 579.05, 579.26, 579.22, 579.38, 579.1, 577.95, 578.12, 579.75, 580.85, 580.41, 579.96, 579.61, 578.76, 578.18, 577.21, 577.13, 579.1, 578.25, 577.91, 576.89, 575.96, 576.8, 577.68, 578.38, 578.52, 579.74, 579.31, 579.89, 579.96))
plot(x) # plot it

a <- acf(x) # ACF
pa <- pacf(x) # PACF

xest <- arima0(x,order=c(1,1,2)) # ARIMA (ar=1,i=1,ma=2)
print(xest)

plot(xest$resid) # Plot: Residuen
hist(xest$resid) # Plot: Histogramm
qqnorm(xest$resid) # QQ-Plot

p <- predict(xest,n.ahead=5) # Prognose
print(p) # print details
plot(as.ts(c(x,p$pred))) # plot x and prediction

# now add vertical line and confidence lines (95%)
lines(c(length(x),length(x)),c(min(x),max(x)), col="red")
lines(c((length(x)+1):(length(x)+5)), c(p$pred+1.96*p$se), col="blue")
lines(c((length(x)+1):(length(x)+5)), c(p$pred-1.96*p$se), col="blue")
Posted by okh at 2007年05月14日 11:19
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。