# 001 001 005 01 1

• Homework Help
• wang6971
• 7

This preview shows page 3 - 7 out of 7 pages.

> mydata=ts.intersect(cmort,trend,temp,temp2,part,partnew)> summary(aov(lm(cmort~cbind(trend,temp,temp2,part,partnew),data=mydata)))Df Sum Sq Mean Sq F value Pr(>F) cbind(trend, temp, temp2, part, partnew) 5 30539 6108 154.5 <2e-16 ***Residuals 498 19687 40 ---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1> num=length(cmort)> AIC(fit)/num-log(2*pi)[1] 4.721732
> BIC(fit)/num-log(2*pi)[1] 4.771699> AICc=log(sum(resid(fit)^2)/num)+(num+5)/(num-5-2)
3.code> library(astsa)> par(mfrow=c(2,2),mar=c(2.5,2.5,0,0)+0.5,mgp=c(1.6,0.6,0))> for(i in 1:4){}> for(i in 1:4){+ x=ts(cumsum(rnorm(100,0.01,1)))+ regx=lm(x~0+time(x),na.action=NULL)+ plot(x,ylab='Random Walk w Drigt')+ abline(a=0,b=0.01,col=2,lty=2)+ abline(regx,col=4)+ }> > summary(regx)Call:lm(formula = x ~ 0 + time(x), na.action = NULL)Residuals:Min 1Q Median 3Q Max -4.6121 -1.1525 0.6403 1.9113 7.9274
Coefficients:Estimate Std. Error t value Pr(>|t|) time(x) -0.128595 0.005536 -23.23 <2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 3.22 on 99 degrees of freedomMultiple R-squared: 0.845, Adjusted R-squared: 0.8434 F-statistic: 539.6 on 1 and 99 DF, p-value: < 2.2e-16> par(mfrow=c(2,2),mar=c(2.5,2.5,0,0)+0.5,mgp=c(1.6,0.6,0))> for(i in 1:4){+ y=rnorm(100,0.01,1)+0.01*time(x)+ regy=lm(x~0+time(y),na.action=NULL)+ plot(y,ylab='Linear trend plus noise')+ abline(a=0,b=0.01,col=2,lty=2)+ abline(regy,col=4)+ }> summary(regy)Call:lm(formula = x ~ 0 + time(y), na.action = NULL)Residuals:Min 1Q Median 3Q Max -4.6121 -1.1525 0.6403 1.9113 7.9274 Coefficients:Estimate Std. Error t value Pr(>|t|) time(y) -0.128595 0.005536 -23.23 <2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 3.22 on 99 degrees of freedomMultiple R-squared: 0.845, Adjusted R-squared: 0.8434 F-statistic: 539.6 on 1 and 99 DF, p-value: < 2.2e-16> par(mfrow=c(2,2),mar=c(2.5,2.5,0,0)+0.5,mgp=c(1.6,0.6,0))> for(i in 1:4){+ y=rnorm(100,0.01,1)+0.01*time(x)+ regy=lm(x~0+time(y),na.action=NULL)+ plot(y,ylab='Linear trend plus noise')+ abline(a=0,b=0.01,col=2,lty=2)+ abline(regy,col=4)+ }> summary(regy)Call:lm(formula = x ~ 0 + time(y), na.action = NULL)Residuals:Min 1Q Median 3Q Max -4.6121 -1.1525 0.6403 1.9113 7.9274
Coefficients:Estimate Std. Error t value Pr(>|t|) time(y) -0.128595 0.005536 -23.23 <2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 3.22 on 99 degrees of freedomMultiple R-squared: 0.845, Adjusted R-squared: 0.8434 F-statistic: 539.6 on 1 and 99 DF, p-value: < 2.2e-16