Page 312 - Applied Statistics with R
P. 312
312 CHAPTER 14. TRANSFORMATIONS
⎧ − 1
{ ≠ 0
( ) = ⎨
{
⎩ log( ) = 0
The parameter is chosen by numerically maximizing the log-likelihood,
( ) = − log( / ) + ( − 1) ∑ log( ).
2
A 100(1 − )% confidence interval for is,
1
̂
{ ∶ ( ) > ( ) − 2 }
2 1,
which R will plot for us to help quickly select an appropriate value. We often
choose a “nice” value from within the confidence interval, instead of the value
of that truly maximizes the likelihood.
library(MASS)
library(faraway)
Here we need the MASS package for the boxcox() function, and we will consider
a couple of datasets from the faraway package.
First we will use the savings dataset as an example of using the Box-Cox
method to justify the use of no transformation. We fit an additive multiple
regression model with sr as the response and each of the other variables as
predictors.
savings_model = lm(sr ~ ., data = savings)
We then use the boxcox() function to find the best transformation of the form
considered by the Box-Cox method.
boxcox(savings_model, plotit = TRUE)

