-
-
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
fea57f0
commit 5da8ba8
Showing
2 changed files
with
59 additions
and
72 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 |
---|---|---|
@@ -1,57 +1,51 @@ | ||
# weightit, multinom | ||
|
||
Code | ||
print(model_parameters(fit4)) | ||
print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE) | ||
Output | ||
# Response level: 2 | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
----------------------------------------------------------------- | ||
(Intercept) | 1.68e-03 | 0.62 | [-1.22, 1.22] | 2.71e-03 | 0.998 | ||
treat | 0.07 | 0.24 | [-0.39, 0.54] | 0.31 | 0.755 | ||
age | -0.03 | 0.01 | [-0.05, -0.01] | -2.38 | 0.018 | ||
educ | -0.02 | 0.05 | [-0.11, 0.08] | -0.33 | 0.738 | ||
Parameter | Odds Ratio | SE | 95% CI | z | p | ||
-------------------------------------------------------------- | ||
(Intercept) | 1.00 | 0.62 | [0.30, 3.39] | 0.00 | 0.998 | ||
treat | 1.08 | 0.25 | [0.68, 1.71] | 0.31 | 0.755 | ||
age | 0.97 | 0.01 | [0.95, 0.99] | -2.38 | 0.018 | ||
educ | 0.98 | 0.05 | [0.89, 1.08] | -0.33 | 0.738 | ||
# Response level: 3 | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
---------------------------------------------------------------- | ||
(Intercept) | -3.01 | 0.71 | [-4.40, -1.61] | -4.23 | < .001 | ||
treat | 0.16 | 0.25 | [-0.32, 0.64] | 0.67 | 0.502 | ||
age | -1.70e-04 | 0.01 | [-0.02, 0.02] | -0.01 | 0.989 | ||
educ | 0.18 | 0.05 | [ 0.08, 0.29] | 3.51 | < .001 | ||
Parameter | Odds Ratio | SE | 95% CI | z | p | ||
--------------------------------------------------------------- | ||
(Intercept) | 0.05 | 0.04 | [0.01, 0.20] | -4.23 | < .001 | ||
treat | 1.18 | 0.29 | [0.73, 1.91] | 0.67 | 0.502 | ||
age | 1.00 | 0.01 | [0.98, 1.02] | -0.01 | 0.989 | ||
educ | 1.20 | 0.06 | [1.08, 1.33] | 3.51 | < .001 | ||
Message | ||
Uncertainty intervals (equal-tailed) 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. | ||
|
||
# weightit, ordinal | ||
|
||
Code | ||
print(model_parameters(fit5)) | ||
print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE) | ||
Output | ||
# Fixed Effects | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
---------------------------------------------------------------- | ||
treat | 0.11 | 0.19 | [-0.25, 0.48] | 0.60 | 0.549 | ||
age | -7.77e-03 | 9.97e-03 | [-0.03, 0.01] | -0.78 | 0.436 | ||
educ | 0.11 | 0.04 | [ 0.03, 0.18] | 2.70 | 0.007 | ||
Parameter | Odds Ratio | SE | 95% CI | z | p | ||
------------------------------------------------------------ | ||
treat | 1.12 | 0.21 | [0.78, 1.61] | 0.60 | 0.549 | ||
age | 0.99 | 0.01 | [0.97, 1.01] | -0.78 | 0.436 | ||
educ | 1.11 | 0.04 | [1.03, 1.20] | 2.70 | 0.007 | ||
# Intercept | ||
Parameter | Log-Odds | SE | 95% CI | z | p | ||
---------------------------------------------------------- | ||
1|2 | 1.19 | 0.52 | [0.17, 2.20] | 2.30 | 0.022 | ||
2|3 | 2.29 | 0.51 | [1.28, 3.29] | 4.47 | < .001 | ||
Parameter | Odds Ratio | SE | 95% CI | z | p | ||
------------------------------------------------------------- | ||
1|2 | 3.28 | 1.70 | [1.19, 9.04] | 2.30 | 0.022 | ||
2|3 | 9.84 | 5.03 | [3.61, 26.81] | 4.47 | < .001 | ||
Message | ||
Uncertainty intervals (equal-tailed) 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. | ||
|
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 |
---|---|---|
@@ -1,50 +1,43 @@ | ||
skip_if_not_installed("WeightIt") | ||
skip_if_not_installed("cobalt") | ||
skip_if_not_installed("insight", minimum_version = "0.20.4") | ||
skip_if_not_installed("withr") | ||
|
||
withr::local_options( | ||
list(parameters_warning_exponentiate = TRUE), | ||
test_that("weightit, multinom", { | ||
data("lalonde", package = "cobalt") | ||
set.seed(1234) | ||
# Logistic regression ATT weights | ||
w.out <- WeightIt::weightit( | ||
treat ~ age + educ + married + re74, | ||
data = lalonde, | ||
method = "glm", | ||
estimand = "ATT" | ||
) | ||
lalonde$re78_3 <- factor(findInterval(lalonde$re78, c(0, 5e3, 1e4))) | ||
test_that("weightit, multinom", { | ||
data("lalonde", package = "cobalt") | ||
set.seed(1234) | ||
# Logistic regression ATT weights | ||
w.out <- WeightIt::weightit( | ||
treat ~ age + educ + married + re74, | ||
data = lalonde, | ||
method = "glm", | ||
estimand = "ATT" | ||
) | ||
lalonde$re78_3 <- factor(findInterval(lalonde$re78, c(0, 5e3, 1e4))) | ||
|
||
fit4 <- WeightIt::multinom_weightit( | ||
re78_3 ~ treat + age + educ, | ||
data = lalonde, | ||
weightit = w.out | ||
) | ||
expect_snapshot(print(model_parameters(fit4))) | ||
}) | ||
) | ||
fit4 <- WeightIt::multinom_weightit( | ||
re78_3 ~ treat + age + educ, | ||
data = lalonde, | ||
weightit = w.out | ||
) | ||
expect_snapshot(print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE)) | ||
}) | ||
|
||
withr::local_options( | ||
list(parameters_warning_exponentiate = TRUE), | ||
test_that("weightit, ordinal", { | ||
data("lalonde", package = "cobalt") | ||
set.seed(1234) | ||
# Logistic regression ATT weights | ||
w.out <- WeightIt::weightit( | ||
treat ~ age + educ + married + re74, | ||
data = lalonde, | ||
method = "glm", | ||
estimand = "ATT" | ||
) | ||
lalonde$re78_3 <- factor(findInterval(lalonde$re78, c(0, 5e3, 1e4))) | ||
test_that("weightit, ordinal", { | ||
data("lalonde", package = "cobalt") | ||
set.seed(1234) | ||
# Logistic regression ATT weights | ||
w.out <- WeightIt::weightit( | ||
treat ~ age + educ + married + re74, | ||
data = lalonde, | ||
method = "glm", | ||
estimand = "ATT" | ||
) | ||
lalonde$re78_3 <- factor(findInterval(lalonde$re78, c(0, 5e3, 1e4))) | ||
|
||
fit5 <- WeightIt::ordinal_weightit( | ||
ordered(re78_3) ~ treat + age + educ, | ||
data = lalonde, | ||
weightit = w.out | ||
) | ||
expect_snapshot(print(model_parameters(fit5))) | ||
}) | ||
) | ||
fit5 <- WeightIt::ordinal_weightit( | ||
ordered(re78_3) ~ treat + age + educ, | ||
data = lalonde, | ||
weightit = w.out | ||
) | ||
expect_snapshot(print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE)) | ||
}) |