3

I have writen code for a Box-Cox transformation (see below). But now I want to do a Yeo-Johnson transformation because datc$plot contains zeros. I tried, but I didn't find a solution.

lambda.fm1 <- boxcox(datc$plot ~ datc$cond.evlot*datc$cond.dl*datc$version), 
                     family="yjPower")
lambda.max <- lambda.fm1$x[which.max(lambda.fm1$y)]
require(car)
datc$plott <- bcPower(datc$plot, lambda = lambda.max, jacobian.adjusted = FALSE)
Glen_b
  • 257,508
  • 32
  • 553
  • 939
Daniel Big
  • 31
  • 1
  • 2
  • in the first line I don`t write "family="yjPower". – Daniel Big May 28 '13 at 08:56
  • 3
    Hi Daniel, welcome to the site. You don't have to code it yourself. The Yeo-Johnson transformations are implemented in the [`car` package](http://cran.r-project.org/web/packages/car/car.pdf) with the function `yjPower`. So just use `yjPower(datc$plot, lambda=lambda.max, jacobian.adjusted=FALSE)`. I think that should work. – COOLSerdash May 28 '13 at 09:12
  • Thanks @ COOLSerdash I tried, but the problem is in the fist line: – Daniel Big May 28 '13 at 09:24
  • 2
    Okay, then try to use the function `boxCox` from the `car` package and use it with the option `family="yjPower"`. – COOLSerdash May 28 '13 at 09:26
  • 3
    See the `yeo.johnson` [function](http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/VGAM/html/yeo.johnson.html) in the package `VGAM` as well. It is on CRAN. – Glen_b May 28 '13 at 12:07

1 Answers1

5

From a recent update (2013, August 04th), caret R package (see page 97) also supports Y-J power transformation.

Andre Silva
  • 3,070
  • 5
  • 28
  • 55
Leo5188
  • 151
  • 1
  • 3
  • I'm looking for the inverse of Yeo-Johnson Transformation in R. Could you please give a link on a package/function. – Nick Mar 26 '17 at 02:24