-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
78 lines (54 loc) · 2.34 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
70
71
72
73
74
75
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
out.width = "70%",
fig.align = "center",
fig.width = 6,
fig.asp = .618,
fig.pos = "H"
)
options(digits = 3)
```
# propensityml <a href='https://github.com/ygeunkim/propensityml'><img src='man/figures/logo.png' align="right" height="139" /></a>
<!-- badges: start -->
[![Travis build status](https://travis-ci.com/ygeunkim/propensityml.svg?branch=master)](https://travis-ci.com/ygeunkim/propensityml)
[![Codecov test coverage](https://codecov.io/gh/ygeunkim/propensityml/branch/master/graph/badge.svg)](https://codecov.io/gh/ygeunkim/propensityml?branch=master)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
<!-- badges: end -->
## Overview
This is an R package to help the [SKKU modern statistical methods project](https://github.com/ygeunkim/psweighting-ml). It is basically based on the paper
[Lee, B. K., Lessler, J., & Stuart, E. A. (2010). Improving propensity score weighting using machine learning. Statistics in Medicine, 29(3), 337–346. doi:10.1002/sim.3782](https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.3782)
## Installation
```{r, eval=FALSE}
# install.packages("remotes")
remotes::install_github("ygeunkim/propensityml")
```
## Usage
`propensityml` package aims at estimating propensity score with machine learning methods as in the paper mentioned above.
```{r}
library(propensityml)
```
The package provides simulation function that generates the dataset in the paper:
[Setoguchi, S., Schneeweiss, S., Brookhart, M. A., Glynn, R. J., & Cook, E. F. (2008). Evaluating uses of data mining techniques in propensity score estimation: a simulation study. Pharmacoepidemiology and Drug Safety, 17(6), 546–555 https://doi.org/10.1002/pds.1555](https://onlinelibrary.wiley.com/doi/abs/10.1002/pds.1555)
and additional toy datasets. Consider simulation.
The most simplest scenario, i.e. additivity and linearity model:
```{r}
(x <- sim_outcome(1000, covmat = build_covariate()))
```
```{r}
(fit_rf <-
x %>%
ps_rf(exposure ~ . - y - exposure_prob, data = .))
```
We have defined the class named `propmod` for some usage.
```{r}
class(fit_rf)
```
Estimating propensity score:
```{r}
estimate_ps(fit_rf) %>% head()
```