-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
84 lines (53 loc) · 2.92 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
76
77
78
79
80
81
82
83
84
---
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%"
)
```
# svycdiff <img src="man/figures/logo.png" align="right" height="120" alt="" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/salernos/svycdiff/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/salernos/svycdiff/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
Propensity score methods are broadly employed with observational data as a tool to achieve covariate balance, but how to implement them in complex surveys is less studied -- in particular, when the survey weights depend on the group variable under comparison.
In this package, we focus on the specific case when sample selection depends the comparison groups of interest. We implement identification formulas to properly estimate the *average controlled difference (ACD)*, or under stronger assumptions, the *population average treatment effect (ATE)* in outcomes between groups, with appropriate weighting for both covariate imbalance and generalizability.
This packages also contains the code necessary to reproduce the motivating data analysis in *"What's the weight? Estimating controlled outcome differences in complex surveys for health disparities research."* This analysis focuses on data from the National Health and Nutrition Examination Survey (NHANES), investigating the interplay of race and social determinants of health when our interest lies in estimating racial differences in mean telomere length.
## Installation
You can install the development version of svycdiff like so:
```{r, eval = FALSE}
#--- CRAN Version
install.packages("svycdiff")
#--- Development Version
# install.packages("devtools")
devtools::install_github("salernos/svycdiff")
```
## Example
This is a basic example usage via simulated data:
```{r example, eval = FALSE}
library(svycdiff)
N <- 1000
dat <- simdat(N)
S <- rbinom(N, 1, dat$P_S_cond_AX)
samp <- dat[S == 1,]
y_mod <- Y ~ A * X
a_mod <- A ~ X
s_mod <- P_S_cond_AX ~ A + X
fit <- svycdiff(samp, "OM", a_mod, s_mod, y_mod, "gaussian")
fit
```
## Vignette
Once you have `svycdiff` installed, you can type
```{r, eval = FALSE}
vignette("svycdiff")
```
in `R` to bring up a tutorial on `svycdiff` and how to use it. To access the vignettes in the developer version, please install the package with
```{r, eval = FALSE}
devtools::install_github("salernos/svycdiff", build_vignettes = TRUE)
```
## Questions
For technical details on the method, see please refer to Salerno et al. (2024+) *"What's the weight? Estimating controlled outcome differences in complex surveys for health disparities research."* To reproduce the analysis results for the main paper, see `inst/nhanes.Rmd`. For questions and comments, please contact Stephen Salerno (<ssalerno@fredhutch.org>).