# This sample program demonstrates how transformations # can be employed to make simple linear model applicable # for complicated relation between "y" and "x" # Here we use 3.16 on P148 in NKNW to illustrate # tranformations on the response variable # Created by C. Andy Tsao t<-matrix(scan("CH03PR15.DAT"),ncol=2,byrow=T) solution <-data.frame(conc=t[,1],time=t[,2]) attach(solution) # Numerical Summary summary(solution) # Graphical Displays plot(time,conc,main="Concentration (Y) vs Time (X)") windows() par(mfrow=c(2,2)); m0<-lm(conc~time) summary(m0) plot.lm(m0) # Exam the prelim analysis: numerical and graphical summaries # Box-Cox Transformation (Use (3.33)) y1<-conc^(-.2); y2<-conc^(-.1); y3<-log(conc); y4<-conc^(.1); y5<-conc^(.2); x<-time; m1<-lm(y1~x); m2<-lm(y2~x); m3<-lm(y3~x); m4<-lm(y4~x); m5<-lm(y5~x); summary(m1);summary(m2);summary(m3);summary(m4);summary(m5); windows(); par(mfrow=c(2,2)); plot(x,y1);abline(coef(m1)); plot(x,y2);abline(coef(m2)); plot(x,y3);abline(coef(m3)); plot(x,y4);abline(coef(m4)); plot(x,y5);abline(coef(m5)); windows(); par(mfrow=c(2,2)); plot.lm(m1); windows(); par(mfrow=c(2,2)); plot.lm(m2); windows(); par(mfrow=c(2,2)); plot.lm(m3); windows(); par(mfrow=c(2,2)); plot.lm(m4); windows(); par(mfrow=c(2,2)); plot.lm(m5); # Question: # Use scatterplots and residual analyses to # Find out some appropriate models and explain # why you choose them.