easystats / performance

:muscle: Models' quality and performance metrics (R2, ICC, LOO, AIC, BF, ...)
https://easystats.github.io/performance/
GNU General Public License v3.0
965 stars 87 forks source link

check_predictions() fails when outcome is log-transformed and named like a valid function #722

Open mattansb opened 1 month ago

mattansb commented 1 month ago
library(performance)

mtcars$rt <- mtcars$mpg

these work…

model <- lm(log(mpg) ~ disp, data = mtcars)
check_predictions(model)

model <- lm(sqrt(rt) ~ disp, data = mtcars)
check_predictions(model)

model <- lm((rt) ~ disp, data = mtcars)
check_predictions(model)

these doens’t - why?

model <- lm(log(rt) ~ disp, data = mtcars)
check_predictions(model)
#> Error in exp(i) - plus_minus: non-numeric argument to binary operator

Created on 2024-05-17 with reprex v2.1.0

mattansb commented 1 month ago

Okay, this happens if the outcome is named like any valid R function...

library(performance)

mtcars$lapply <- mtcars$mpg

model <- lm(log(lapply) ~ disp, data = mtcars)
check_predictions(model)
#> Error in exp(i) - plus_minus: non-numeric argument to binary operator

mtcars$binned_residuals <- mtcars$mpg

model <- lm(log(binned_residuals) ~ disp, data = mtcars)
check_predictions(model)
#> Error in exp(i) - plus_minus: non-numeric argument to binary operator