Extracting lambda value with highest log-likelihood from boxcox output

library(MASS)
bc <- boxcox(Volume ~ log(Height) + log(Girth), data = trees)


To find the $\lambda$ value with the highest log-likelihood, this command could be used:

bc$x[which.max(bc$y)]


Is x=log(Height) in this example?

-
I was going to ask whether you consulted the documentation for boxcox, but I read it myself and realized it is utterly useless: it doesn't say anything about what is actually getting transformed. Consulting this recent blog by Arthur Charpentier may help set you straight. –  whuber Dec 20 '12 at 14:56
bc returns a list with two entries. Because your command is supposed to give the lambda value with the highest log-likelihood, I would say that lambda values are in the x-entry while the corresponding log-likelihood values are in the y-entry. Just a guess. –  ocram Dec 20 '12 at 15:10

No, x is not log(Height). If you write bc$x then you are extracting$\lambda$from the bc object. The bc object gives two values x and y. The x referes to the$\lambda\$ (or x axis) and y refers to the value of the log-likelihood. Check out this clip.

-

If you only grab the highest lambda from that analysis then you are missing the point of the function and its return. Part of what it is trying to show you (look at the graph that it produces) is that there is a region of reasonable lambda values. You should use this and knowledge of the science behind the data to choose a reasonable value. If the "best" lambda value is 0.43, but the interval includes 0.5 and there is a meaningful reason why a square root transform makes sense then using 0.5 is better in many ways than using 0.43 even though it gives the maximum.

The original paper by Box and Cox talked about understanding the science and finding reasonble candidates for lambda, not just trying everything and using the maximum value even when there is no justification (and there is justification for other values that are almost as good).

-