I am trying to make boxcox transformation of a variable (ie sqrt.CR) with lambda value from -2 to 2. On running the below R code it gives a error of invalid atomic vectors. Later on checking earlier posts i saw few suggestions to transform the matrix into a data frame. Though the error continued to show up. Do anyone know to figure out this error ?
R code.
Matrix to data frame conversion
drivers.data<-as.data.frame(drivers)
Boxcox transfrom.
drivers$box_CR<-boxcox(drivers.data$sqrt.CR,lambda=seq(-2,2))
The input to boxcox must be the output of a lm or aov call, not a vector of numbers as yours appears to be. See ?boxcox
.
boxcox(object, ...)
Arguments:
object: a formula or fitted model object. Currently only 'lm' and 'aov' objects are handled.
It could be because of package conflict, in MASS,boxcox requires a model object lm, whereas in bestNormalize it requires a vector.
Try
bestNormalize::boxcox(drivers.data)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.