Skip to content

Commit a73960f

Browse files
committed
Doc, namespace, and vignette updates
1 parent 1519afe commit a73960f

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Imports:
2323
chk (>= 0.9.2),
2424
rlang (>= 1.1.0),
2525
crayon (>= 1.3.4),
26+
sandwich,
2627
generics,
2728
utils,
2829
stats
@@ -41,7 +42,6 @@ Suggests:
4142
fwb (>= 0.2.0),
4243
splines,
4344
marginaleffects (>= 0.19.0),
44-
sandwich,
4545
MASS,
4646
gbm (>= 2.1.9),
4747
dbarts (>= 0.9-29),

NAMESPACE

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ S3method(as.weightit,weightit.fit)
55
S3method(as.weightitMSM,default)
66
S3method(calibrate,default)
77
S3method(calibrate,weightit)
8-
S3method(generics::estfun,multinom_weightit)
9-
S3method(generics::estfun,ordinal_weightit)
108
S3method(generics::glance,coxph_weightit)
119
S3method(generics::glance,glm_weightit)
1210
S3method(generics::glance,multinom_weightit)
@@ -32,6 +30,12 @@ S3method(print,summary.weightit.sbps)
3230
S3method(print,summary.weightitMSM)
3331
S3method(print,weightit)
3432
S3method(print,weightitMSM)
33+
S3method(sandwich::bread,glm_weightit)
34+
S3method(sandwich::bread,multinom_weightit)
35+
S3method(sandwich::bread,ordinal_weightit)
36+
S3method(sandwich::estfun,glm_weightit)
37+
S3method(sandwich::estfun,multinom_weightit)
38+
S3method(sandwich::estfun,ordinal_weightit)
3539
S3method(stats::anova,coxph_weightit)
3640
S3method(stats::anova,glm_weightit)
3741
S3method(stats::anova,multinom_weightit)
@@ -83,8 +87,9 @@ import(stats)
8387
importFrom(crayon,italic)
8488
importFrom(crayon,strikethrough)
8589
importFrom(crayon,underline)
86-
importFrom(generics,estfun)
8790
importFrom(generics,glance)
8891
importFrom(generics,tidy)
8992
importFrom(graphics,hist)
9093
importFrom(graphics,plot)
94+
importFrom(sandwich,bread)
95+
importFrom(sandwich,estfun)

man/glm_weightit-methods.Rd

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/WeightIt.Rmd

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ editor_options:
1919
knitr::opts_chunk$set(echo = TRUE, eval=TRUE)
2020
options(width = 200, digits= 4)
2121
22-
me_ok <- requireNamespace("marginaleffects", quietly = TRUE)
22+
me_ok <- requireNamespace("marginaleffects", quietly = TRUE) && !isTRUE(as.logical(Sys.getenv("NOT_CRAN", "false")))
2323
set.seed(1000)
2424
```
2525

@@ -97,7 +97,7 @@ fit <- lm_weightit(re78 ~ treat * (age + educ + race + married +
9797
# G-computation for the treatment effect
9898
library("marginaleffects")
9999
avg_comparisons(fit, variables = "treat",
100-
newdata = subset(lalonde, treat == 1))
100+
newdata = subset(treat == 1))
101101
```
102102

103103
Our confidence interval for `treat` contains 0, so there isn't evidence that `treat` has an effect on `re78`. Several types of standard errors are available in `WeightIt`, including analytical standard errors that account for estimation of the weights using M-estimation, robust standard errors that treat the weights as fixed, and bootstrapping. All type are described in detail at `vignette("estimating-effects")`.
@@ -141,7 +141,7 @@ Wmsm.out <- weightitMSM(list(A_1 ~ X1_0 + X2_0,
141141
Wmsm.out
142142
```
143143

144-
No matter which method is selected, `weightitMSM()` estimates separate weights for each time period and then takes the product of the weights for each individual to arrive at the final estimated weights. Printing the output of `weightitMSM()` provides some details about the function call and the output. We can take a look at the quality of the weights with `summary()`, just as we could for point treatments.
144+
`weightitMSM()` estimates separate weights for each time period and then takes the product of the weights for each individual to arrive at the final estimated weights. Printing the output of `weightitMSM()` provides some details about the function call and the output. We can take a look at the quality of the weights with `summary()`, just as we could for point treatments.
145145

146146
```{r}
147147
summary(Wmsm.out)
@@ -171,11 +171,10 @@ Then, we compute the average expected potential outcomes under each treatment re
171171
```{r, eval = me_ok}
172172
library("marginaleffects")
173173
(p <- avg_predictions(fit,
174-
variables = c("A_1", "A_2", "A_3"),
175-
type = "response"))
174+
variables = c("A_1", "A_2", "A_3")))
176175
```
177176

178-
We can compare the expected potential outcomes under each regime using `marginaleffects::hypotheses()`. To get all pairwise comparisons, supply the `avg_predictions()` output to `hypotheses(., "pairwise")`. To compare individual regimes, we can use `hypotheses()`, identifying the rows of the `avg_predictions()` output. For example, to compare the regimes with no treatment for all three time points vs. the regime with treatment for all three time points, we would run
177+
We can compare the expected potential outcomes under each regime using `marginaleffects::hypotheses()`. To get all pairwise comparisons, supply the `avg_predictions()` output to `hypotheses(., ~ pairwise)`. To compare individual regimes, we can use `hypotheses()`, identifying the rows of the `avg_predictions()` output. For example, to compare the regimes with no treatment for all three time points vs. the regime with treatment for all three time points, we would run
179178

180179
```{r, eval = me_ok}
181180
hypotheses(p, "b8 - b1 = 0")

vignettes/estimating-effects.Rmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pre code {
3131
knitr::opts_chunk$set(echo = TRUE, eval = TRUE)
3232
options(width = 200, digits= 4)
3333
34-
me_ok <- requireNamespace("marginaleffects", quietly = TRUE)
34+
me_ok <- requireNamespace("marginaleffects", quietly = TRUE) && !isTRUE(as.logical(Sys.getenv("NOT_CRAN", "false")))
3535
me_ok_new <- me_ok && utils::packageVersion("marginaleffects") > "0.25.0.1"
3636
su_ok <- requireNamespace("survival", quietly = TRUE)
3737
```
@@ -582,12 +582,12 @@ hypotheses(a, ~pairwise)
582582

583583
Though the subgroup effects differ from each other in the sample, this difference is not statistically significant at the .05 level, so there is no evidence of moderation by `X5`.
584584

585-
When the moderator has more than two levels, it is possible to run an omnibus test for moderation by changing `hypothesis` to `"reference"` and supplying the output to `hypotheses()` with `joint = TRUE`, e.g.,
585+
When the moderator has more than two levels, it is possible to run an omnibus test for moderation by changing `hypothesis` to `~reference` and supplying the output to `hypotheses()` with `joint = TRUE`, e.g.,
586586

587587
```{r, eval=FALSE}
588588
avg_comparisons(fit, variables = "A",
589589
by = "X5",
590-
hypothesis = ~pairwise) |>
590+
hypothesis = ~reference) |>
591591
hypotheses(joint = TRUE)
592592
```
593593

0 commit comments

Comments
 (0)