-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
70 lines (49 loc) · 1.55 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# propensity <img src="man/figures/logo.png" align="right" height="138" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/malcolmbarrett/propensity/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/malcolmbarrett/propensity/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of propensity is to calculate propensity scores and weights for a wide variety of research questions.
propensity is under very early development.
## Installation
You can install the development version of propensity from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("r-causal/propensity")
```
## Example
propensity is under very early development. Currently, it supports calculating propensity score weights for binary exposures:
```{r}
library(propensity)
propensity_scores <- c(.1, .3, .4, .3)
x <- c(0, 0, 1, 0)
# ATE weights
wt_ate(propensity_scores, .exposure = x)
# Stabilized ATE weights
wt_ate(propensity_scores, .exposure = x, stabilize = TRUE)
# ATO weights
wt_ato(propensity_scores, .exposure = x)
```
```{r example, include = FALSE, eval = FALSE}
library(propensity)
ps <- propensity(
model,
exposure,
stabilizer = model2,
exposure_type = "categorical"
)
match(ps, data)
data |>
mutate(wts = wts(ps, estimand = "att"))
```