library(AID)
out <- boxcoxnc(data, method = "mle", lambda = seq(-2,2,0.0001), verbose = F, plot = F)
out$lambda.hat
## [1] -0.0474
library(MASS)
out <- boxcox(data~1, lambda = seq(-2,2,0.0001), plotit = F)
out$x[which.max(out$y)]
## [1] -0.0474
library(car)
out <- powerTransform(data, family = "bcPower")
out$lambda
## data
## -0.04740941
confInt(out, level = 0.95)
## Back transformed data
## ---------------------------------------------
## Mean 2.5% 97.5%
## data 549.3418 379.9816 800.8924
## ---------------------------------------------
confInt(out, level = 0.99)
## Back transformed data
## ---------------------------------------------
## Mean 0.5% 99.5%
## data 549.3418 334.4112 916.3863
## ---------------------------------------------
library(forecast)
best_lambda=forecast::BoxCox.lambda(data)
data1=forecast::BoxCox(data,lambda=best_lambda)
#用给定的λ对变换之后的数据进行逆变换还原
data2=forecast::InvBoxCox(data1,lambda=best_lambda)