Git Product home page Git Product logo

Comments (2)

strengejacke avatar strengejacke commented on July 29, 2024

tab_model() relies on performance::performance_aic() to get the AIC. That function returns a corrected AIC for transformed response-values, which is more accurate, since the underlying "variation" in the data should be similar if the raw data is the same. See example and links to docs:

m <- c(5000, 360)
s <- c(2000, 50)
r <- -0.75
sigma <- sqrt(log(s^2/m^2 + 1))
mu <- log(m) - sigma^2/2
rho <- log(r*prod(s)/prod(m) + 1)

# Random data generation
library(MASS)
n <- 50
set.seed(2)
dados <- exp(mvrnorm(n = n, mu = mu, Sigma = diag(sigma^2 - rho) + rho,
            empirical = TRUE))
colnames(dados) <- c("PU", "Area")
dados <- as.data.frame(dados)

# Wrong fit:
wfit <- lm(PU ~ Area, data = dados)

# Good fit:
fit <- lm(log(PU)~log(Area), data = dados)

# comparable results
performance::performance_aic(wfit)
#> [1] 863.5921
performance::performance_aic(fit)
#> [1] 844.8888

see ?performance::performance_aic:

performance_aic() correctly detects transformed response and, unlike stats::AIC(), returns the "corrected" AIC value on the original scale. To get back to the original scale, the likelihood of the model is multiplied by the Jacobian/derivative of the transformation.

See also https://easystats.github.io/performance/reference/performance_aicc.html and https://easystats.github.io/insight/reference/get_loglikelihood.html (argument check_response).

from sjplot.

lfpdroubi avatar lfpdroubi commented on July 29, 2024

Perfect, @strengejacke! Although I think you should use different argument names (just suggesting), like show_adj_aic and show_aic. Then it would be clear to the user of your package what's happening behind the courtains. Thanks a lot!

from sjplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.