-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Wald tests - differences across packages #509
Labels
3 investigators ❔❓
Need to look further into this issue
Comments
Might be due to the binomial family. For linear models, results are the same for m1 <- lm(mpg ~ disp + hp + drat, data = mtcars)
m2 <- lm(mpg ~ disp + hp, data = mtcars)
m3 <- lm(mpg ~ disp, data = mtcars)
rez <- performance::test_wald(m1, m2, m3)
ref1 <- lmtest::waldtest(m1, m2, m3, test = "F")
ref2 <- anova(m1, m2, m3, test = "F")
rez
#> Name | Model | df | df_diff | F | p
#> ------------------------------------------
#> m1 | lm | 28 | | |
#> m2 | lm | 29 | -1.00 | 3.33 | 0.079
#> m3 | lm | 30 | -1.00 | 3.72 | 0.064
#> Models were detected as nested and are compared in sequential order.
ref1
#> Wald test
#>
#> Model 1: mpg ~ disp + hp + drat
#> Model 2: mpg ~ disp + hp
#> Model 3: mpg ~ disp
#> Res.Df Df F Pr(>F)
#> 1 28
#> 2 29 -1 3.3319 0.07863 .
#> 3 30 -1 3.4438 0.07368 .
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ref2
#> Analysis of Variance Table
#>
#> Model 1: mpg ~ disp + hp + drat
#> Model 2: mpg ~ disp + hp
#> Model 3: mpg ~ disp
#> Res.Df RSS Df Sum of Sq F Pr(>F)
#> 1 28 253.35
#> 2 29 283.49 -1 -30.148 3.3319 0.07863 .
#> 3 30 317.16 -1 -33.665 3.7207 0.06393 .
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Created on 2022-10-30 with reprex v2.0.2 |
Weird indeed... wouldn't a Wald test for a glm use a chi-sq? |
anova and lmtest still differ for chisq, but the default behaviour of anova is just no test, I think: m1 <- glm(vs ~ disp + hp + drat, data = mtcars, family = "binomial")
m2 <- glm(vs ~ disp + hp, data = mtcars, family = "binomial")
m3 <- glm(vs ~ disp, data = mtcars, family = "binomial")
lmtest::waldtest(m1, m2, m3, test = "Chisq")
#> Wald test
#>
#> Model 1: vs ~ disp + hp + drat
#> Model 2: vs ~ disp + hp
#> Model 3: vs ~ disp
#> Res.Df Df Chisq Pr(>Chisq)
#> 1 28
#> 2 29 -1 2.0444 0.15276
#> 3 30 -1 2.9782 0.08439 .
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(m1, m2, m3, test = "Chisq")
#> Analysis of Deviance Table
#>
#> Model 1: vs ~ disp + hp + drat
#> Model 2: vs ~ disp + hp
#> Model 3: vs ~ disp
#> Resid. Df Resid. Dev Df Deviance Pr(>Chi)
#> 1 28 12.869
#> 2 29 16.750 -1 -3.8802 0.04886 *
#> 3 30 22.696 -1 -5.9462 0.01475 *
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# default behaviour
anova(m1, m2, m3)
#> Analysis of Deviance Table
#>
#> Model 1: vs ~ disp + hp + drat
#> Model 2: vs ~ disp + hp
#> Model 3: vs ~ disp
#> Resid. Df Resid. Dev Df Deviance
#> 1 28 12.869
#> 2 29 16.750 -1 -3.8802
#> 3 30 22.696 -1 -5.9462 Created on 2022-10-31 with reprex v2.0.2 |
strengejacke
added a commit
that referenced
this issue
Oct 31, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2022-10-30 with reprex v2.0.2
@DominiqueMakowski @mattansb @bwiernik (or someone else)
Any ideas?
The text was updated successfully, but these errors were encountered: