Last active
December 9, 2015 13:57
-
-
Save artemklevtsov/fdabcbabea253caa9161 to your computer and use it in GitHub Desktop.
Box−Cox transformation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Box-Cox transformation | |
box_cox <- function(x, lambda = 0) { | |
stopifnot(is.numeric(x)) | |
stopifnot(is.numeric(lambda)) | |
if (lambda == 0) | |
x <- log(x) | |
else | |
x <- (x^lambda - 1L) / lambda | |
return(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment