网站大量收购闲置独家精品文档,联系QQ:2885784924

R语言时间序列作业.docx

  1. 1、本文档共18页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
R语言时间序列作业

2016年第二学期时间序列分析及应用R语言课后作业 第三章 趋势 3.4(a) data(hours);plot(hours,ylab=Monthly Hours,type=o) 画出时间序列图 (b) data(hours);plot(hours,ylab=Monthly Hours,type=l) type=o 表示每个数据点都叠加在曲线上;type=b 表示在曲线上叠加数据点,但是该数据点附近是断开的;type=l 表示只显示各数据点之间的连接线段;type=p 只想显示数据点。 points(y=hours,x=time(hours),pch=as.vector(season(hours))) 3.10(a) data(hours);hours.lm=lm(hours~time(hours)+I(time(hours)^2));summary(hours.lm) 用最小二乘法拟合二次趋势,结果显示如下: Call: lm(formula = hours ~ time(hours) + I(time(hours)^2)) Residuals: Min 1Q Median 3Q Max -1.00603 -0.25431 -0.02267 0.22884 0.98358 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -5.122e+05 1.155e+05 -4.433 4.28e-05 *** time(hours) 5.159e+02 1.164e+02 4.431 4.31e-05 *** I(time(hours)^2) -1.299e-01 2.933e-02 -4.428 4.35e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.423 on 57 degrees of freedom Multiple R-squared: 0.5921, Adjusted R-squared: 0.5778 F-statistic: 41.37 on 2 and 57 DF, p-value: 7.97e-12 (b) plot(y=rstudent(hours.lm),x=as.vector(time(hours)),type=l,ylab=Standardized Residuals) points(y=rstudent(hours.lm),x=as.vector(time(hours)),pch=as.vector(season(hours))) 标准残差的时间序列,应用月度绘图标志。(为了更容易识别季节性) 带季节性图标的的残差-时间图 (c) runs(rstudent(hours.lm)) 对标准差进行游程检验 $pvalue [1] 0.00012 $observed.runs [1] 16 $expected.runs [1] 30.96667 $n1 [1] 31 $n2 [1] 29 $k [1] 0 结果解释:P值为0.00012,表明非随机性是合理的。 (d) acf(rstudent(hours.lm)) 标准残差的样本自相关函数 季节均值模型残差的样本自相关系数 (e) qqnorm(rstudent(hours.lm));qqline(rstudent(hours.lm)) (QQ图) 正态性可以通过正态得分或者分位数-分位数(QQ)图来检验。此处的直线型图形支持了该模型中随机项是正态分布的假设。 hist(rstudent(hours.lm),xlab=Standardized Residuals) 标准残差的直方图(季节均值模型的标准残差直方图) shapiro.test(rstudent(hours.lm)) 正态性检验(Shapiro-Wilk检验)本质是:计算残差与相应的正态分位数之间的相关系数。相关性越小,就越有理由否定正态性。 Shapiro-Wilk normality test data: rstudent(hours.lm) W = 0.99385, p-value = 0.9909 根据上面的检验结果,我们不能拒绝模型的随机项是正态分布的假设。 第四章 平稳时间序列模型 4.4 第五章 非平稳时间序列模型 5.1(a) ARMA (2,1) p=

文档评论(0)

shuwkb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档