library(TSA) set.seed(43712) n=40 for (i in 1:50) { Y=rnorm(n=40) acf(Y,lag.max=20) #readline() } Y=ts(rnorm(n=40)) plot(Y) mean(Y) runs(Y) data(tempdub) plot(tempdub) month.=season(tempdub) # the period sign is included to make the printout from # the commands two line below clearer; ditto below. model2=lm(tempdub~month.-1) # -1 removes the intercept term summary(model2) plot(residuals(model2)) res=ts(rstudent(model2),start=c(1964,1),freq=12) plot(res) n=144 qnorm(.025/n) #Bonferroni abline(h=qnorm(.025/n),col='red') abline(h=-qnorm(.025/n),col='red') acf(res) runs(res) har.=harmonic(tempdub,1) model4b=lm(tempdub~har.) summary(model4b) res=ts(rstudent(model4b),start=c(1964,1),freq=12) plot(res) n=144 qnorm(.025/n) #Bonferroni abline(h=qnorm(.025/n),col='red') abline(h=-qnorm(.025/n),col='red') acf(res) acf(as.vector(res)) runs(res) plot(y=res,x=fitted(model4b)) abline(h=0,col='blue') qqnorm(res) qqline(res)