Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.
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?

share|improve this question
1  
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
add comment

2 Answers

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.

share|improve this answer
add comment

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.