Backtransformation function for preProcess function from Caret package

I don't think that your usage is appropriate. For example, since you give it the entire data set, the spatial sign computation will have your predictor data being dependent on the outcome data (and vice-versa).

Can you describe what you are trying to do? If you are just interested in the Box-Cox transform of the outcome, I suggest using the MASS or car packages. An example is below but take a look at this book for a longer discussion.

library(car)
#> Loading required package: carData

data(ames, package = "modeldata")

ames <- ames[, c("Sale_Price", "Year_Built", "Latitude", "Longitude")]
ames <- as.data.frame(ames)

with(
  ames, 
  boxCox(Sale_Price ~ Year_Built + Latitude + Longitude, data = ames)
)

Created on 2021-05-07 by the reprex package (v1.0.0.9000)

1 Like