-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94f0267
commit 9835b52
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# print warning about complete separation | ||
|
||
Code | ||
print(out) | ||
Output | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
------------------------------------------------------------------------------ | ||
(Intercept) | -66.10 | 1.83e+05 | [-10644.72, 10512.52] | -3.60e-04 | > .999 | ||
x1 | 15.29 | 27362.84 | [ -3122.69, ] | 5.59e-04 | > .999 | ||
x2 | 6.24 | 81543.72 | [-12797.28, ] | 7.65e-05 | > .999 | ||
Message | ||
Uncertainty intervals (profile-likelihood) and p-values (two-tailed) | ||
computed using a Wald z-distribution approximation. | ||
The model has a log- or logit-link. Consider using `exponentiate = | ||
TRUE` to interpret coefficients as ratios. | ||
Note that some coefficients are very large, which may indicate issues | ||
with complete separation. | ||
|
||
--- | ||
|
||
Code | ||
print(out) | ||
Output | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
------------------------------------------------------------------------- | ||
(Intercept) | -83.33 | 15505.03 | [ , 816.56] | -5.37e-03 | 0.996 | ||
gear | 21.01 | 3876.26 | [-248.93, ] | 5.42e-03 | 0.996 | ||
Message | ||
Uncertainty intervals (profile-likelihood) and p-values (two-tailed) | ||
computed using a Wald z-distribution approximation. | ||
The model has a log- or logit-link. Consider using `exponentiate = | ||
TRUE` to interpret coefficients as ratios. | ||
Note that some coefficients are very large, which may indicate issues | ||
with complete separation. | ||
|
||
# print warning about quasi complete separation | ||
|
||
Code | ||
print(out) | ||
Output | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
------------------------------------------------------------------ | ||
(Intercept) | -56.36 | 21.45 | [-114.76, -25.33] | -2.63 | 0.009 | ||
qsec | 3.12 | 1.19 | [ 1.40, 6.37] | 2.62 | 0.009 | ||
Message | ||
Uncertainty intervals (profile-likelihood) and p-values (two-tailed) | ||
computed using a Wald z-distribution approximation. | ||
The model has a log- or logit-link. Consider using `exponentiate = | ||
TRUE` to interpret coefficients as ratios. | ||
Note that some coefficients are very large, which may indicate issues | ||
with (quasi) complete separation. Consider using bias-corrected or | ||
penalized regression models. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
skip_if(getRversion() < "4.0.0") | ||
skip_if_not_installed("withr") | ||
|
||
withr::with_options( | ||
list("parameters_warning_exponentiate" = TRUE), | ||
Check warning on line 5 in tests/testthat/test-complete_separation.R GitHub Actions / lint-changed-files / lint-changed-files
|
||
{ | ||
test_that("print warning about complete separation", { | ||
d_sep <- data.frame( | ||
y = c(0, 0, 0, 0, 1, 1, 1, 1), | ||
x1 = c(1, 2, 3, 3, 5, 6, 10, 11), | ||
x2 = c(3, 2, -1, -1, 2, 4, 1, 0) | ||
) | ||
m_sep <- suppressWarnings(glm(y ~ x1 + x2, data = d_sep, family = binomial)) | ||
out <- model_parameters(m_sep) | ||
expect_snapshot(print(out)) | ||
}) | ||
} | ||
) | ||
|
||
withr::with_options( | ||
list("parameters_warning_exponentiate" = TRUE), | ||
Check warning on line 21 in tests/testthat/test-complete_separation.R GitHub Actions / lint-changed-files / lint-changed-files
|
||
{ | ||
test_that("print warning about complete separation", { | ||
data(mtcars) | ||
m_sep2 <- suppressWarnings(glm(am ~ gear, data = mtcars, family = binomial)) | ||
out <- model_parameters(m_sep2) | ||
expect_snapshot(print(out)) | ||
}) | ||
} | ||
) | ||
|
||
withr::with_options( | ||
list("parameters_warning_exponentiate" = TRUE), | ||
Check warning on line 33 in tests/testthat/test-complete_separation.R GitHub Actions / lint-changed-files / lint-changed-files
|
||
{ | ||
test_that("print warning about quasi complete separation", { | ||
data(mtcars) | ||
m_sep3 <- suppressWarnings(glm(vs ~ qsec, data = mtcars, family = binomial)) | ||
out <- model_parameters(m_sep3) | ||
expect_snapshot(print(out)) | ||
}) | ||
} | ||
) |