R程序与时间序列分析

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1.时序图程序:da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]m=da[,2]basicStats(m)plot(y,m,type='l')title(main='financialincomeofChina:1978-2010')2.取对数:da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]logm=log(da[,2])basicStats(logm)plot(y,logm,type='l')title(main='financialincomeofChina:1978-2010')3.一阶差分:da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]dy1=diff(log(da[,2]),lag=1)basicStats(dy1)plot(dy1,type='l')title(main='financialincomeofChina:1978-2010')4、对取对数之后的一阶差分序列作ACF、PACF检验:da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]dy1=diff(log(da[,2]),lag=1)basicStats(dy1)plot(dy1,type='l')title(main='financialincomeofChina:1978-2010')acf(dy1,lag.max=16)x1=acf(dy1,lag.max=16)names(x1)x1$acfx2-pacf(dy1,lag.max=16)names(x2)x2$acfBox.test(dy1,lag=5,type=Ljung)5模型定阶(1)ARMA(1,1):m1=arima(dy1,order=c(1,0,1))dy1(2)AR(1)dy2=arima(dy1,order=c(1,0,0))dy2(3)MA(1)dy3=arima(dy1,order=c(0,0,1))dy36.模型的建立da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]m=da[,2]d=y^2f-function(m,y){m=a+b*y+c*d}lm.reg-lm(m~1+y+d)summary(lm.reg)7.模型的检验op-par(mfrow=c(2,2))plot(lm.reg)par(op)8.对残差序列进行白噪声检验Box.test(m,lag=5,type=Ljung)9.对残差序列进行自相关分析和偏自相关分析da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]m=da[,2]d=y^2f-function(m,y){m=a+b*y+c*d}lm.reg-lm(m~1+y+d)Summary(lm.reg)Box.test(m,lag=5,type=Ljung)acf(m,lag.max=16)x1=acf(m,lag.max=16)names(x1)x1$acfx2-pacf(m,lag.max=16)names(x2)x2$acfBox.test(dy1,lag=5,type=Ljung)10.采用MA(4)拟合残差序列:da-read.table(d:/ss.txt,header=T)dim(da)y=da[,1]m=da[,2]d=y^2f-function(m,y){m=a+b*y+c*d}lm.reg-lm(m~1+y+d)summary(lm.reg)Box.test(m,lag=5,type=Ljung)acf(m,lag.max=16)x1=acf(m,lag.max=16)x1$acfx2-pacf(m,lag.max=16)x2$acfBox.test(dy1,lag=5,type=Ljung)m2=arima(m,order=c(0,0,4))m211.模型预测predict(m1,3)

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功