时间序列分析及应用:R语言(第三章)

时间序列分析及应用:R语言 机械工业出版社(2011年)
主要是书中代码实现和简单梳理笔记

3 趋势

3.1 确定性趋势与随机趋势

3.2 常数均值的估计

3.3 回归方法

# 线性时间趋势的最小二乘回归估计
library(TSA)
data(rwalk)
model1 = lm(rwalk~time(rwalk))
summary(model1)

# 随机游动与线性时间趋势
win.graph(width=4.875, height=2.5,pointsize=8)
plot(rwalk,type='o',ylab='y')
abline(model1)

# 季节均值模型回归结果
data(tempdub)
month.=season(tempdub) # period added to improve table display
model2=lm(tempdub~month.-1) # -1 removes the intercept term
summary(model2)

# 带截距项的季节均值模型回归结果
model3=lm(tempdub~month.) # January is dropped automatically
summary(model3)

# 气温序列的余弦趋势模型
har.=harmonic(tempdub,1)
model4=lm(tempdub~har.)
summary(model4)

# 气温序列的余弦趋势图
win.graph(width=4.875,height=2.5,pointsize=8)
plot(ts(fitted(model4),freq=12,start=c(1964,1)),ylab='Temperature',type='l',ylim=range(c(fitted(model4),tempdub)))
points(tempdub) # ylim ensures that the y axis range fits the raw data and the fitted values


3.4 回归估计的可靠性和有效性

3.5 回归结果的解释

3.6 残差分析

# 气温季节均值的残差-时间图
plot(y=rstudent(model3),x=as.vector(time(tempdub)),xlab='Time',ylab='Standardized Residuals',type='o')

# 带季节性图标的残差-时间图
plot(y=rstudent(model3),x=as.vector(time(tempdub)),xlab='Time',ylab='Standardized Residuals',type='l')
points(y=rstudent(model3),x=as.vector(time(tempdub)),pch=as.vector(season(tempdub)))

# 气温季节均值模型标准残差与拟合值
plot(y=rstudent(model3),x=as.vector(fitted(model3)),xlab='Fitted Trend Values',ylab='Standardized Residuals',type='n')
points(y=rstudent(model3),x=as.vector(fitted(model3)),pch=as.vector(season(tempdub)))

# 季节均值模型标准残差直方图
hist(rstudent(model3),xlab='Standardized Residuals')

# QQ图:季节均值模型的标准残差
win.graph(width=2.5,height=2.5,pointsize=8)
qqnorm(rstudent(model3))

# 季节均值模型残差的样本自相关系数
win.graph(width=4.875,height=3,pointsize=8)
acf(rstudent(model3))

# 用直线拟合随机游动得到的残差
plot(y=rstudent(model1),x=as.vector(time(rwalk)),ylab='Standardized Residuals',xlab='Time',type='o')

# 残差与来自拟合直线的拟合值
win.graph(width=4.875,height=3,pointsize=8)
plot(y=rstudent(model1),x=fitted(model1),ylab='Standardized Residuals',xlab='Fitted Trend Line Values',type='p')

# 来自直线模型残差的样本自相关
acf(rstudent(model1))

# 洛杉矶降雨量序列分位数-分位数图
win.graph(width=2.5,height=2.5,pointsize=8)
qqnorm(larain)
qqline(larain)

3.7 小结

本章的主要内容是描述、建模和估计时间序列的确定性趋势。最简单的确定性趋势是常数均值函数。估计常数均值的方法已经给出,但更重要的是研究了在不同条件下对估计量准确度的评估。然后,使用回归方法来估计时间上的线性或二次的趋势。接下来是关于周期性或季节性趋势建模的方法,还研究了所有这些回归方法的可靠性和有效性,最后一节开启了用于研究拟合模型品质的残差分析工作,并引入了非常重要、贯穿本书其他部分反复涉及的样本自相关函数。

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值