Does the response in the savings data need transformation? You'll need a function from the "MASS" library for performing Box-Cox transformation. Read in the library:
Try it out on the savings dataset:
> savings <- read.table("savings.data")
> g <- lm(sav ~ p15 + p75 + inc + gro,
> boxcox(g, plotit=T)
> boxcox(g, plotit=T, lambda=seq(0.5,1.5,by=0.1))
The confidence interval for lambda is from 0.6 to about 1.4. What do we conclude?
We can see that there is no good reason to transform.
Now consider the Galapagos data analyzed earlier:
> gala <- read.table("gala.data")
> gg <- lm(Species~Area+Elevation+Nearest+Scruz+Adjacent, data=gala)
> boxcox(gg, plotit=T)
> boxcox(gg, lambda=seq(0.0,1.0,by=0.05), plotit=T)
The confidence interval for lambda is from 0.1 to about 0.5. What do we conclude?
We see that perhaps a cube-root transformation might be best here.
A square root is also a possibility as this falls just within the confidence intervals. Certainly there is a strong need to transform.
Let's see if the gro variable in the savings dataset needs transformation:
> g <- lm(sav ~ p15 + p75 + gro + inc,
> g2 <- update(g, . ~ . + I(gro*log(gro))) # Add gro*log(gro) to the model
Examine the coefficient of gro*log(gro) - what should we conclude?
Now see if p15 should be transformed.
> g3 <- update(g, . ~ . + I(p15*log(p15))) ; summary(g3)
Compare the results of this test to the partial residual plot for p15.