Here is how to use Box-Cox transform on Exploratory.
For this, I found this answer on stackoverflow useful. Here I’m basically reproducing this on Exploratory.
Here is how the data we want to apply Box-Cox transform look like.
On Table View:
On Summary View:
Here is the script I borrowed from the stackoverflow answer. Define this function in a Script.
powerTransform <- function(y, lambda1, lambda2 = NULL, method = "boxcox") {
boxcoxTrans <- function(x, lam1, lam2 = NULL) {
# if we set lambda2 to zero, it becomes the one parameter transformation
lam2 <- ifelse(is.null(lam2), 0, lam2)
if (lam1 == 0L) {
log(y + lam2)
} else {
(((y + lam2)^lam1) - 1) / lam1
}
}
switch(method
, boxcox = boxcoxTrans(y, lambda1, lambda2)
, tukey = y^lambda1
)
}
Here is detail on how to create a Script.
I’m skipping on how to figure out the right value on lambda, but for this data, it’s 0.4242424.
In this case, we can add a mutate step that looks like this to apply Box-Cox transformation on y.
y_transformed column is added.
Here is how it looks on Summary View, where we can see it is distributed more normally.