0
$\begingroup$

I have a dependent variable Cost and an independent variable VPT. I want to perform a power transformation on VPTwith the Box-Cox Transformation.

In the end I am looking for something like this:

C~ I(VPT^(lambda))

What are the steps to get lambda? I read it is possible to do it with the library Mass, but I am also open for other options to get lambda.

$\endgroup$
9
  • $\begingroup$ The point is that a Box-Cox program (command, function, ...) estimates it for you. $\endgroup$
    – Nick Cox
    Commented Apr 22, 2014 at 12:55
  • $\begingroup$ I know, and I am wondering how to use the Box-Cox program? $\endgroup$
    – ustroetz
    Commented Apr 22, 2014 at 12:56
  • $\begingroup$ Software-specific questions are off-topic here. Even in a software-based forum, you have to ask questions that don't invite the answer "Read the documentation". $\endgroup$
    – Nick Cox
    Commented Apr 22, 2014 at 12:59
  • $\begingroup$ This question appears to be off-topic because it is about how to use a specific piece of software. Nor would it be suitable for Stack Overflow. $\endgroup$
    – Nick Cox
    Commented Apr 22, 2014 at 13:00
  • 1
    $\begingroup$ @Nick I don't agree - software specific questions have always been on topic, as long as there's a statistical element to the question ("what are the steps to get lambda?" meets that criterion to my eyes, or potentially does). The most popular tag on CV is actually r. $\endgroup$
    – Glen_b
    Commented Apr 22, 2014 at 13:23

1 Answer 1

0
$\begingroup$

Since the Box-Cox transformation is typically used on the dependent variable, you could try doing this (which I think would still be valid):

  1. Model your independent variable (I.V.) as a function of your dependent variable (D.V.)
  2. Use the boxcox function in MASS to estimate lambda
  3. Switch the variables in the (backwards) model above (so that D.V. ~ I.V.) and check the model fit with and without the estimated lambda.

For example:

set.seed(123)
y1 <- rnorm(200,10,2)
set.seed(321)
x1 <- .8*(y1^3)-rnorm(200)
##
require(MASS)
lm.xy <- lm(x1~y1) ## first model I.V. ~ D.V.
boxcox(lm.xy) ## for graph
bcTest <- boxcox(lm.xy,plotit=FALSE) ## for output
lambda <- bcTest$x[which.max(bcTest$y)] ## estimate of optimal lambda
## reverse your first model so that D.V. ~ I.V. 
## and compare with and without transformation:
lm0.yx <- lm(y1~x1)
lm1.yx <- lm(y1~I(((x1^lambda)-1)/lambda))
summary(lm0.yx)
summary(lm1.yx)

I am not completely positive that this is a valid approach so (anyone) please feel free to correct me if I'm wrong or if you have a better suggestion.

$\endgroup$

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