-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
e7f6c44
commit 45eee0d
Showing
7 changed files
with
145 additions
and
3 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
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
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
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
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,31 @@ | ||
# model parameters ------------------- | ||
|
||
#' @export | ||
model_parameters.ordinal_weightit <- model_parameters.clm2 | ||
|
||
#' @export | ||
model_parameters.multinom_weightit <- model_parameters.bracl | ||
|
||
# CI --------------------- | ||
|
||
#' @export | ||
ci.ordinal_weightit <- ci.clm2 | ||
|
||
#' @export | ||
ci.multinom_weightit <- ci.bracl | ||
|
||
# standard errors ----------------- | ||
|
||
#' @export | ||
standard_error.ordinal_weightit <- standard_error.clm2 | ||
|
||
#' @export | ||
standard_error.multinom_weightit <- standard_error.bracl | ||
|
||
# p values ---------------- | ||
|
||
#' @export | ||
p_value.ordinal_weightit <- p_value.clm2 | ||
|
||
#' @export | ||
p_value.multinom_weightit <- p_value.bracl |
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,51 @@ | ||
# weightit, multinom | ||
|
||
Code | ||
print(model_parameters(fit4)) | ||
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 | ||
# 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 | ||
Message | ||
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed | ||
using a Wald z-distribution approximation. | ||
|
||
# weightit, ordinal | ||
|
||
Code | ||
print(model_parameters(fit5)) | ||
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 | ||
# 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 | ||
Message | ||
Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed | ||
using a Wald z-distribution approximation. | ||
|
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,43 @@ | ||
skip_if_not_installed("WeightIt") | ||
skip_if_not_installed("cobalt") | ||
skip_if_not_installed("insight", minimum_version = "0.20.4") | ||
|
||
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))) | ||
}) | ||
|
||
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))) | ||
}) |