{"id":17867677,"url":"https://github.com/ngreifer/weightit","last_synced_at":"2025-05-16T08:03:18.768Z","repository":{"id":37548520,"uuid":"111706644","full_name":"ngreifer/WeightIt","owner":"ngreifer","description":"WeightIt: an R package for propensity score weighting","archived":false,"fork":false,"pushed_at":"2025-04-10T21:02:19.000Z","size":14781,"stargazers_count":112,"open_issues_count":8,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-16T08:02:45.725Z","etag":null,"topics":["causal-inference","inverse-probability-weights","observational-study","propensity-scores","r"],"latest_commit_sha":null,"homepage":"https://ngreifer.github.io/WeightIt/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngreifer.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-22T16:17:18.000Z","updated_at":"2025-04-10T20:56:00.000Z","dependencies_parsed_at":"2023-01-21T12:01:05.686Z","dependency_job_id":"851b744f-70d9-4304-ad5f-234ffb8a5a85","html_url":"https://github.com/ngreifer/WeightIt","commit_stats":{"total_commits":881,"total_committers":3,"mean_commits":293.6666666666667,"dds":0.004540295119182747,"last_synced_commit":"c026cee438c2b836ddcd0f375f8dbe0ae9be72e7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngreifer%2FWeightIt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngreifer%2FWeightIt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngreifer%2FWeightIt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngreifer%2FWeightIt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngreifer","download_url":"https://codeload.github.com/ngreifer/WeightIt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493381,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-inference","inverse-probability-weights","observational-study","propensity-scores","r"],"created_at":"2024-10-28T09:55:01.005Z","updated_at":"2025-05-16T08:03:18.695Z","avatar_url":"https://github.com/ngreifer.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = FALSE,\n  warning = FALSE,\n  message = FALSE,\n  tidy = FALSE,\n  fig.align='center',\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\"\n)\n```\n# WeightIt: Weighting for Covariate Balance in Observational Studies \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"150\"/\u003e\n\n[![CRAN status](https://www.r-pkg.org/badges/version/WeightIt?color=00622B)](https://CRAN.R-project.org/package=WeightIt)\n[![CRAN_Downloads_Badge](https://cranlogs.r-pkg.org/badges/WeightIt?color=00622B)](https://cran.r-project.org/package=WeightIt)\n\n### Overview\n\n*WeightIt* is a one-stop package to generate balancing weights for point and longitudinal treatments in observational studies. Support is included for binary, multi-category, and continuous treatments, a variety of estimands including the ATE, ATT, ATC, ATO, and others, and support for a wide variety of weighting methods, including those that rely on parametric modeling, machine learning, or optimization. *WeightIt* also provides functionality for fitting regression models in weighted samples that account for estimation of the weights in quantifying uncertainty. *WeightIt* uses a familiar formula interface and is meant to complement `MatchIt` as a package that provides a unified interface to basic and advanced weighting methods.\n\nFor a complete vignette, see the [website](https://ngreifer.github.io/WeightIt/articles/WeightIt.html) for *WeightIt* or `vignette(\"WeightIt\")`.\n\nTo install and load *WeightIt*, use the code below:\n\n```{r, eval = FALSE}\n#CRAN version\npak::pkg_install(\"WeightIt\")\n\n#Development version\npak::pkg_install(\"ngreifer/WeightIt\")\n\nlibrary(\"WeightIt\")\n```\n```{r, include = FALSE}\nlibrary(\"WeightIt\")\n```\n\nThe workhorse function of *WeightIt* is `weightit()`, which generates weights from a given formula and data input according to methods and other parameters specified by the user. Below is an example of the use of `weightit()` to generate propensity score weights for estimating the ATT:\n\n```{r}\ndata(\"lalonde\", package = \"cobalt\")\n\nW \u003c- weightit(treat ~ age + educ + nodegree + \n                married + race + re74 + re75, \n              data = lalonde, method = \"glm\", \n              estimand = \"ATT\")\nW\n```\n\nEvaluating weights has two components: evaluating the covariate balance produced by the weights, and evaluating whether the weights will allow for sufficient precision in the eventual effect estimate. For the first goal, functions in the *cobalt* package, which are fully compatible with *WeightIt*, can be used, as demonstrated below:\n\n```{r}\nlibrary(\"cobalt\")\n\nbal.tab(W, un = TRUE)\n```\n\nFor the second goal, qualities of the distributions of weights can be assessed using `summary()`, as demonstrated below.\n\n```{r}\nsummary(W)\n```\n\nLarge effective sample sizes imply low variability in the weights, and therefore increased precision in estimating the treatment effect.\n\nFinally, we can estimate the effect of the treatment using a weighted outcome model, accounting for estimation of the weights in the standard error of the effect estimate:\n\n```{r}\nfit \u003c- lm_weightit(re78 ~ treat, data = lalonde,\n                   weightit = W)\n\nsummary(fit, ci = TRUE)\n```\n\nThe tables below contain the available methods in *WeightIt* for estimating weights for binary, multi-category, and continuous treatments. Some of these methods require installing other packages to use; see `vignette(\"installing-packages\")` for information on how to install them.\n \n#### Binary Treatments\n\n Method               | `method`\n -------------------- | --------\n Binary regression PS | [`\"glm\"`](https://ngreifer.github.io/WeightIt/reference/method_glm.html)\n Generalized boosted modeling PS | [`\"gbm\"`](https://ngreifer.github.io/WeightIt/reference/method_gbm.html)\n Covariate balancing PS | [`\"cbps\"`](https://ngreifer.github.io/WeightIt/reference/method_cbps.html)\n Non-Parametric covariate balancing PS | [`\"npcbps\"`](https://ngreifer.github.io/WeightIt/reference/method_npcbps.html)\n Entropy balancing | [`\"ebal\"`](https://ngreifer.github.io/WeightIt/reference/method_ebal.html)\n Inverse probability tilting | [`\"ipt\"`](https://ngreifer.github.io/WeightIt/reference/method_ipt.html)\n Stable balancing weights | [`\"optweight\"`](https://ngreifer.github.io/WeightIt/reference/method_optweight.html)\n SuperLearner PS | [`\"super\"`](https://ngreifer.github.io/WeightIt/reference/method_super.html)\n Bayesian additive regression trees PS | [`\"bart\"`](https://ngreifer.github.io/WeightIt/reference/method_bart.html)\n Energy balancing | [`\"energy\"`](https://ngreifer.github.io/WeightIt/reference/method_energy.html)\n\n#### Multi-Category Treatments\n \n Method               | `method`\n -------------------- | --------\n Multinomial regression PS | [`\"glm\"`](https://ngreifer.github.io/WeightIt/reference/method_glm.html)\n Generalized boosted modeling PS | [`\"gbm\"`](https://ngreifer.github.io/WeightIt/reference/method_gbm.html)\n Covariate balancing PS | [`\"cbps\"`](https://ngreifer.github.io/WeightIt/reference/method_cbps.html)\n Non-parametric covariate balancing PS | [`\"npcbps\"`](https://ngreifer.github.io/WeightIt/reference/method_npcbps.html)\n Entropy balancing | [`\"ebal\"`](https://ngreifer.github.io/WeightIt/reference/method_ebal.html)\n Inverse probability tilting | [`\"ipt\"`](https://ngreifer.github.io/WeightIt/reference/method_ipt.html)\n Stable balancing weights | [`\"optweight\"`](https://ngreifer.github.io/WeightIt/reference/method_optweight.html)\n SuperLearner PS | [`\"super\"`](https://ngreifer.github.io/WeightIt/reference/method_super.html)\n Bayesian additive regression trees PS | [`\"bart\"`](https://ngreifer.github.io/WeightIt/reference/method_bart.html)\n Energy balancing | [`\"energy\"`](https://ngreifer.github.io/WeightIt/reference/method_energy.html)\n \n#### Continuous Treatments\n \n Method               | `method`\n -------------------- | --------\n Generalized linear model GPS | [`\"glm\"`](https://ngreifer.github.io/WeightIt/reference/method_glm.html)\n Generalized boosted modeling GPS | [`\"gbm\"`](https://ngreifer.github.io/WeightIt/reference/method_gbm.html)\n Covariate balancing GPS | [`\"cbps\"`](https://ngreifer.github.io/WeightIt/reference/method_cbps.html)\n Non-parametric covariate balancing GPS | [`\"npcbps\"`](https://ngreifer.github.io/WeightIt/reference/method_npcbps.html)\n Entropy balancing | [`\"ebal\"`](https://ngreifer.github.io/WeightIt/reference/method_ebal.html)\n Stable balancing weights | [`\"optweight\"`](https://ngreifer.github.io/WeightIt/reference/method_optweight.html)\n SuperLearner GPS | [`\"super\"`](https://ngreifer.github.io/WeightIt/reference/method_super.html)\n Bayesian additive regression trees GPS | [`\"bart\"`](https://ngreifer.github.io/WeightIt/reference/method_bart.html)\n Distance covariance optimal weighting | [`\"energy\"`](https://ngreifer.github.io/WeightIt/reference/method_energy.html)\n \nIn addition, *WeightIt* implements the subgroup balancing propensity score using the function `sbps()`. Several other tools and utilities are available, including `trim()` to trim or truncate weights, `calibrate()` to calibrate propensity scores, and `get_w_from_ps()` to compute weights from propensity scores.\n\n*WeightIt* provides functions to fit weighted models that account for the uncertainty in estimating the weights. These include `glm_weightit()` for fitting generalized linear models, `ordinal_weightit()` for ordinal regression models, `multinom_weightit()` for multinomial regression models, and `coxph_weightit()` for Cox proportional hazards models. Several methods are available for computing the parameter variances, including asymptotically correct M-estimation-based variances, robust variances that treat the weights as fixed, and traditional and fractional weighted bootstrap variances. Clustered variances are supported. See `vignette(\"estimating-effects\")` for information on how to use these after weighting to estimate treatment effects.\n\nPlease submit bug reports, questions, comments, or other issues to https://github.com/ngreifer/WeightIt/issues. If you would like to see your package or method integrated into *WeightIt*, please contact the author. Fan mail is greatly appreciated.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngreifer%2Fweightit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngreifer%2Fweightit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngreifer%2Fweightit/lists"}