Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R package for estimating balancing weights using optimization

NotificationsYou must be signed in to change notification settings

ngreifer/optweight

Repository files navigation

CRAN_Status_BadgeCRAN_Downloads_Badge

optweight contains functions to estimate stable balancing weights thatbalance covariates up to given thresholds. It solves a convexoptimization problem to minimize a function of the weights that capturestheir variability (or divergence from a set of base weights). This isthe method described in Zubizarreta(2015), Källberg and Waernbaum(2023), and Wang andZubizarreta (2020).optweight extends the method to multi-category, continuous, andmultivariate treatments and provides a simple user interface andcompatibility with thecobaltpackage for balance assessment. Seevignette("optweight") for a morethorough description of the package’s capabilities.

To installoptweight, use the code below:

#CRAN versioninstall.packages("optweight")#Development versionpak::pkg_install("ngreifer/optweight")

Below is an example of estimating weights withoptweight and assessingbalance on the covariates withcobalt.

library("optweight")library("cobalt")data("lalonde")# Estimate weightsow<- optweight(treat~age+educ+race+nodegree+married+re74+re75,data=lalonde,estimand="ATT",tols=.01,min.w=0)ow
#> An optweight object#>  - number of obs.: 614#>  - norm minimized: "l2"#>  - sampling weights: present#>  - base weights: present#>  - treatment: 2-category#>  - estimand: ATT (focal: 1)#>  - covariates: age, educ, race, nodegree, married, re74, re75
# Information about the weightssummary(ow)
#>                   Summary of weights#> #> - Weight ranges:#> #>         Min                                 Max#> treated   1      ||                       1.   #> control   0 |---------------------------| 5.588#> #> - Units with the 5 most extreme weights by group:#>                                      #>             1     2     3     4     5#>  treated    1     1     1     1     1#>           423   388   226   196   118#>  control 5.27 5.298 5.324 5.479 5.588#> #> #> - Weight statistics:#> #>            L2    L1    L∞ # Zeros#> treated 0.    0.    0.          0#> control 1.663 1.302 4.588     231#> #> - Effective Sample Sizes:#> #>            Control Treated#> Unweighted   429.      185#> Weighted     113.9     185
# Covariate balancebal.tab(ow)
#> Balance Measures#>                Type Diff.Adj#> age         Contin.     0.01#> educ        Contin.     0.01#> race_black   Binary     0.01#> race_hispan  Binary     0.00#> race_white   Binary    -0.01#> nodegree     Binary     0.01#> married      Binary    -0.01#> re74        Contin.    -0.01#> re75        Contin.     0.01#> #> Effective sample sizes#>            Control Treated#> Unadjusted   429.      185#> Adjusted     113.9     185

We can see that all standardized mean differences are at or below .01 inabsolute value, as requested using thetols argument. Because we setmin.w = 0, some units received weights of 0, effectively dropping themfrom the sample (by default, the smallest weight allowed is$10^{-8}$).

We can useplot() to examine the dual variables for each constraint,which represent how active that constraint is at the optimal point.Highly active constraints affect the objective function value the mostwhen their tolerances are changed.

plot(ow)

We can see thatrace has the highest dual variable; relaxing theconstraint onrace would yield the biggest improvement in effectivesample size, while tightening its constraint would yield the biggestdecrease in effective sample size.

The lower-level functionoptweight.fit() operates on the covariatesand treatment variables directly.optweightMV() supports multivariate(i.e., multiple) treatments.

In addition to estimating balancing weights for estimating treatmenteffects,optweight can estimate sampling weights for generalizing anestimate to a new target population defined by covariate moments usingoptweight.svy(), which implements the methods described in Jackson,Rhodes, and Ouwens (2021)for matching-adjusted indirect comparison (MAIC).

To citeoptweight, please usecitation("optweight") to generate thecorrect reference. Be sure to include the version of the package. Pleasesubmit bug reports, questions, comments, or other issues tohttps://github.com/ngreifer/optweight/issues.

References

Jackson, Dan, Kirsty Rhodes, and Mario Ouwens. 2021. “AlternativeWeighting Schemes When Performing Matching-Adjusted IndirectComparisons.”Research Synthesis Methods 12 (3): 333–46.https://doi.org/10.1002/jrsm.1466.

Källberg, David, and Ingeborg Waernbaum. 2023. “Large Sample Propertiesof Entropy Balancing Estimators of Average Causal Effects.”Econometrics and Statistics, November.https://doi.org/10.1016/j.ecosta.2023.11.004.

Wang, Yixin, and Jose R. Zubizarreta. 2020. “Minimal DispersionApproximately Balancing Weights: Asymptotic Properties and PracticalConsiderations.”Biometrika 107 (1): 93–105.https://doi.org/10.1093/biomet/asz050.

Zubizarreta, José R. 2015. “Stable Weights That Balance Covariates forEstimation with Incomplete Outcome Data.”Journal of the AmericanStatistical Association 110 (511): 910–22.https://doi.org/10.1080/01621459.2015.1023805.

About

R package for estimating balancing weights using optimization

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp