easystats / insight

:crystal_ball: Easy access to model information for various model objects
https://easystats.github.io/insight/
GNU General Public License v3.0
404 stars 39 forks source link

find_transformation() returning multiple values #971

Closed clayford closed 6 days ago

clayford commented 1 week ago

I'm getting a strange result using find_transformation() .

set.seed(1)
n <- 30
x <- rlnorm(n = n, meanlog = 3, sdlog = 1)
y <- exp(2 + log(x) + rnorm(n, sd = 3))
d <- data.frame(x, y)
m <- lm(log(y) ~ log(x), data = d)
insight::find_transformation(m)

 [1] "log(x+4673.13225311911)"  "log(x+131.010849737221)" 
 [3] "log(x+205.899095737431)"  "log(x+622.575982038046)" 
 [5] "log(x+3.31457397592542)"  "log(x+18.8129963456494)" 
 [7] "log(x+74.036572293308)"   "log(x+259.922761309829)" 
 [9] "log(x+7157.08080203097)"  "log(x+1079.37652118081)" 
[11] "log(x+410.842685009422)"  "log(x+102.489278796646)" 
[13] "log(x+645.257554033513)"  "log(x+86.0810856848207)" 
[15] "log(x+57.896899533129)"   "log(x+16.9892521916613)" 
[17] "log(x+435.962235299268)"  "log(x+3825.46376335103)" 
[19] "log(x+240.851981136965)"  "log(x+3779.03702391604)" 
[21] "log(x+1228.18778047069)"  "log(x+51.7309951376847)" 
[23] "log(x+444.933155106137)"  "log(x+0.685613662493765)"
[25] "log(x+20310.5727180539)"  "log(x+53373.5698604622)" 
[27] "log(x+42.2050576714609)"  "log(x+1.48712352973464)" 
[29] "log(x+508.267979514448)"  "log(x+150.321712673464)" 

I'm running R 4.4.2 and insight 0.20.5. Am I doing something wrong?

Oddly enough, this modified code from the documentation example works as expected:

model <- lm(log(Sepal.Length) ~ log(Sepal.Width), data = iris)
insight::find_transformation(model)

[1] "log"