# # Epage # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # version$language == "R" for R version$language == NULL for SPlus if(is.null(version$language) == FALSE){ require(alr3) }else{ library(alr3) } data(baeskel) attach(baeskel) postscript("../../WriteUp/Graphics/Chapter7/prob_1_orig_scatter_plot.eps", onefile=FALSE, horizontal=FALSE) plot( Sulfur, Tension ) dev.off() # Plot each value of lambda individually: lambdaChoices <- c(-1,0,1) new.sulfur <- seq( min(Sulfur), max(Sulfur), length=100 ) for (j in 1:length(lambdaChoices)) { m1 <- lm( Tension ~ powtran(Sulfur, lambdaChoices[j],modified=FALSE) ) new.fit <- predict( m1, data.frame(Sulfur=new.sulfur) ) lines( new.sulfur, new.fit, lty=j, col=j ) } #legend( locator(1), legend = as.character( lambdaChoices ), lty=1:length(lambdaChoices), col=1:length(lambdaChoices) ) # or use the command in alr3 that automates this: # postscript("../../WriteUp/Graphics/Chapter7/prob_1_independent_power_trans.eps", onefile=FALSE, horizontal=FALSE) inv.tran.plot(Sulfur,Tension,lam=c(-1,0,+1),key=c(0.6,400)) dev.off() # replace Sulfur with its logarithm: # logSulfur <- log(Sulfur) m <- lm( Tension ~ logSulfur ) inv.tran.plot( Tension, predict(m) ) postscript("../../WriteUp/Graphics/Chapter7/prob_1_dependent_power_trans.eps", onefile=FALSE, horizontal=FALSE) inverse.response.plot( m, lam=c(-1,0,+1) ) dev.off() unlist( inv.tran.estimate( Tension, predict(m) ) )