Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do the standardized beta values and CIs of a glm poisson regression model not differ from the unstandardized ones? #403

Open
ludi94 opened this issue Nov 15, 2023 · 8 comments

Comments

@ludi94
Copy link

ludi94 commented Nov 15, 2023

Question and context
For a specific research question i fitted a generalized linear mixed model using a poisson link function due to the characteristics of my data.

For reporting purposes i used the report package and the report function. However, i noticed that the standardized coefficients and CIs are equal to the normal coefficients and CIs.

Can someone explain why?

I also fitted a glm with poisson to a randomly generated dataset and found the same after running the report(model) function.

Here is a minimal example:

# install.packages("report")

library(report)

set.seed(123)
anzahl_unfaelle <- rpois(100, lambda = 3)  # Lambda ist der erwartete Wert
mean(anzahl_unfaelle)
var(anzahl_unfaelle)

wetter <- factor(sample(c("regnerisch", "bewölkt", "sonnig"), 100, replace = TRUE))

daten <- data.frame(anzahl_unfaelle, wetter)

modell <- glm(anzahl_unfaelle ~ wetter, data = daten, family = "poisson")

summary(modell)
report(modell)

The output:

The effect of wetter [regnerisch] is statistically non-significant and positive (beta = 4.45e-03, 95% CI [-0.29, 0.29], p = 0.976; Std. beta = 4.45e-03, 95% CI [-0.29, 0.29])

➞ beta = std. beta
➞ CI = std. CI

I appreciate any help!

Lukas

@mattansb
Copy link
Member

For GLMs, the response is not standardized.
The default standardization method (refit) does not standardize factors.

Therefore, in this model, nothing is standardized.

@ludi94
Copy link
Author

ludi94 commented Nov 15, 2023

Thank you very much for your fast response and the clarification!
Do you know if this is just not implemented or is it more critical to standardize factors in glms compared to lms?

Again, thank you very much!

@mattansb
Copy link
Member

It is not implemented by design: there is no way to "standardize" a non-numeric variable.

parameters::model_parameters() has standardize = "basic" method that standardizes the coefficients by the design matrix. But i don't see that this is implemented here yet, @rempsyc ?

@ludi94
Copy link
Author

ludi94 commented Nov 15, 2023

I am just wondering why i get std. values when i use the same data but fitting a lm instead of glm:
modell <- lm(anzahl_unfaelle ~ wetter, data = daten)
report(modell)

@mattansb
Copy link
Member

Because for gaussian models, the response is standardized.
For GLMs it does not make sense to standardize the response - the scale is not arbitrary, and changing it will qualitatively change the model, and often will just make the model not work (which is not true for gaussian models).

@ludi94
Copy link
Author

ludi94 commented Nov 15, 2023

I see! Thanks a lot!

@strengejacke
Copy link
Member

strengejacke commented Nov 15, 2023

It's not super easy to find, but you can obtain results from different standardization methods using parameters::standardize_parameters():

library(easystats)
#> # Attaching packages: easystats 0.7.0
#> ✔ bayestestR  0.13.1.7     ✔ correlation 0.8.4.9000
#> ✔ datawizard  0.9.0.2      ✔ effectsize  0.8.6.3   
#> ✔ insight     0.19.6.7     ✔ modelbased  0.8.6.4   
#> ✔ performance 0.10.8.1     ✔ parameters  0.21.3.1  
#> ✔ report      0.5.7.13     ✔ see         0.8.1

set.seed(123)
anzahl_unfaelle <- rpois(100, lambda = 3)  # Lambda ist der erwartete Wert
mean(anzahl_unfaelle)
#> [1] 2.94
var(anzahl_unfaelle)
#> [1] 2.622626

wetter <- factor(sample(c("regnerisch", "bewölkt", "sonnig"), 100, replace = TRUE))
daten <- data.frame(anzahl_unfaelle, wetter)

modell <- glm(anzahl_unfaelle ~ wetter, data = daten, family = "poisson")
standardize_parameters(modell, method = "basic")
#> # Standardization method: basic
#> 
#> Parameter        | Std. Coef. |        95% CI
#> ---------------------------------------------
#> (Intercept)      |       0.00 | [ 0.00, 0.00]
#> wetterregnerisch |   1.96e-03 | [-0.13, 0.13]
#> wettersonnig     |       0.03 | [-0.10, 0.16]
#> 
#> - Response is unstandardized.

See also the docs here:
https://easystats.github.io/parameters/reference/standardize_parameters.html

@rempsyc
Copy link
Sponsor Member

rempsyc commented Nov 16, 2023

parameters::model_parameters() has standardize = "basic" method that standardizes the coefficients by the design matrix. But i don't see that this is implemented here yet, @rempsyc ?

Not AFAIK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants