> library(astsa) > ?astsa > ?gtemp > plot(gtemp) > fit=lm(gtemp~time(gtemp)) > summary(fit) Call: lm(formula = gtemp ~ time(gtemp)) Residuals: Min 1Q Median 3Q Max -0.31946 -0.09722 0.00084 0.08245 0.29383 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.120e+01 5.689e-01 -19.69 <2e-16 *** time(gtemp) 5.749e-03 2.925e-04 19.65 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.1251 on 128 degrees of freedom Multiple R-squared: 0.7511, Adjusted R-squared: 0.7492 F-statistic: 386.3 on 1 and 128 DF, p-value: < 2.2e-16 > abline(fit,col=2) > plot(gtemp-fitted(fit)) > ?cmort > ?part > ?tempr > A=cbind(Mortality=cmort,Temperature=tempr,Particulate=part) > pairs(A) > fit=lm(cmort~tempr+part) > summary(fit) Call: lm(formula = cmort ~ tempr + part) Residuals: Min 1Q Median 3Q Max -19.4024 -5.5239 -0.4039 4.7967 29.7985 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 110.54531 3.11851 35.45 <2e-16 *** tempr -0.47824 0.03879 -12.33 <2e-16 *** part 0.28827 0.02309 12.48 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 7.871 on 505 degrees of freedom Multiple R-squared: 0.3828, Adjusted R-squared: 0.3804 F-statistic: 156.6 on 2 and 505 DF, p-value: < 2.2e-16 > ts.plot(cmort,fitted(fit),col=1:2) > pairs(A) > ts.plot(cbind(soi,rec)) > plot.ts(cbind(soi,rec)) > ccf(soi,rec) > fish=ts.intersect(rec,soiL6=lag(soi,-6),dframe=TRUE) > > fish=ts.intersect(rec,soiL6=lag(soi,-6),dframe=TRUE) > fit=lm(rec~soiL6,data=fish) > summary(fit) Call: lm(formula = rec ~ soiL6, data = fish) Residuals: Min 1Q Median 3Q Max -65.187 -18.234 0.354 16.580 55.790 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 65.790 1.088 60.47 <2e-16 *** soiL6 -44.283 2.781 -15.92 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 22.5 on 445 degrees of freedom Multiple R-squared: 0.3629, Adjusted R-squared: 0.3615 F-statistic: 253.5 on 1 and 445 DF, p-value: < 2.2e-16 > ts.plot(cbind(rec,fitted(fit)),col=1:2) Error in .cbind.ts(list(...), .makeNamesTs(...), dframe = FALSE, union = TRUE) : non-time series not of the correct length > ts.plot(cbind(fish$rec,fitted(fit)),col=1:2) > plot(fish$rec,fitted(fit)) > plot(resid(fit)) > ts.plot(resid(fit)) > acf(resid.fit) Error in as.ts(x) : object 'resid.fit' not found > acf(resid(fit)) > plot(fish$rec,fitted(fit)) > ts.plot(cbind(fish$rec,fitted(fit)),col=1:2) > plot(fish$rec,fitted(fit)) > ts.plot(resid(fit)) > plot(gtemp) > fit=lm(gtemp~time(gtemp)) > y1=gtemp-fitted(fit) > plot(y1) > acf(y1) > plot(y1) > y2=diff(gtemp) > plot(y2) > acf(y2) >