# This program reproduces the figures and output of # Cod Catch data of Example 6.1 in Bowerman, O'Connell and Koehler # Created by C. Andy Tsao, 060515 # Change the working directory to where the data is stored # Load packages # foreign for reading Splus data # car for DW test cod<-read.S("t6-1 cod catch.splus") dt<-data.frame(y=cod[,1],t=as.integer(row.names(cod))) dt; attach(dt) # Polynomial regression of 1st and 2nd order m1<-lm(y~t);summary(m1);anova(m1);durbin.watson(m1); plot(t,m1$res) t2<-t^2; m2<-lm(y~t+t2);summary(m2);anova(m2);durbin.watson(m2); rs<-t%%4; # rs = t mod(4) = remainder of t divided by 4 is.factor(rs); cs<-as.factor(rs); summary(cs);summary(rs); mr<-lm(y~rs); summary(mr);anova(mr);durbin.watson(mr); mc<-lm(y~cs); summary(mc);anova(mc);durbin.watson(mc);