Skip to content

Commit bb7ce48

Browse files
committed
add CRE, and GPS example.
1 parent f540d40 commit bb7ce48

57 files changed

Lines changed: 2008 additions & 179 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/_images/example_w_1_covar.pdf

6.84 KB
Binary file not shown.

docs/_images/example_w_1_erf.pdf

5.34 KB
Binary file not shown.

docs/_sources/intro.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ Matching on generalized propensity scores with continuous exposures (Python Pack
5252
5353
Interpretable Subgroups Identification through Ensemble Learning of Causal Rules
5454
55-
[![](http://www.r-pkg.org/badges/version-last-release/CRE)](http://www.r-pkg.org/pkg/cre)
55+
[![](http://www.r-pkg.org/badges/version-last-release/CRE)](https://CRAN.R-project.org/package=CRE)
5656
[![R-CMD-check](https://github.com/nsaph-software/CRE/workflows/R-CMD-check/badge.svg?branch=develop)](https://github.com/nsaph-software/CRE/actions)
57+
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/grand-total/CRE)](http://www.r-pkg.org/pkg/cre)
5758
[![codecov](https://codecov.io/gh/NSAPH-Software/CRE/branch/develop/graph/badge.svg?token=UMSVOYRKGA)](https://codecov.io/gh/NSAPH-Software/CRE)
5859
5960
---
@@ -69,6 +70,7 @@ Gaussian processes for the estimation of causal exposure-response curves (GPCERF
6970
7071
[![](http://www.r-pkg.org/badges/version-last-release/GPCERF)](https://CRAN.R-project.org/package=GPCERF)
7172
[![R build status](https://github.com/NSAPH-Software/GPCERF/workflows/R-CMD-check/badge.svg?branch=develop)](https://github.com/NSAPH-Software/GPCERF/actions)
73+
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/grand-total/GPCERF)](http://www.r-pkg.org/pkg/gpcerf)
7274
[![codecov](https://codecov.io/gh/NSAPH-Software/GPCERF/branch/develop/graph/badge.svg?token=066ISL822N)](https://codecov.io/gh/NSAPH-Software/GPCERF)
7375
7476

docs/_sources/research_gallery/TBD.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# CausalGPS | Example 1
2+
## Matching with parametric GPS model
3+
4+
In this example, we will use the CausalGPS R package to generate pseudo population based on parametric GPS model. We use synthetic Medicare data that is available in the package. All processing are done in R.
5+
6+
Step 1: Install and load the package
7+
8+
```r
9+
install.packages("CausalGPS")
10+
library(CausalGPS)
11+
```
12+
13+
Step 2: Load the data
14+
15+
```r
16+
data("synthetic_us_2010", package = "CausalGPS")
17+
synthetic_us_2010$cdc_mean_bmi[synthetic_us_2010$cdc_mean_bmi > 9000] <- NA
18+
data <- synthetic_us_2010
19+
20+
confounders_s1 <- c("cs_poverty","cs_hispanic",
21+
"cs_black",
22+
"cs_ed_below_highschool",
23+
"cs_median_house_value",
24+
"cs_population_density",
25+
"cdc_mean_bmi","cdc_pct_nvsmoker",
26+
"gmet_mean_summer_tmmx",
27+
"gmet_mean_summer_rmx",
28+
"gmet_mean_summer_sph",
29+
"cms_female_pct", "region"
30+
)
31+
32+
data$region <- as.factor(data$region)
33+
```
34+
35+
Step 3: Generate Pseudo Population
36+
37+
```r
38+
set.seed(574)
39+
ps_pop_obj_1 <- generate_pseudo_pop(data$cms_mortality_pct,
40+
data$qd_mean_pm25,
41+
data.frame(data[, confounders_s1, drop=FALSE]),
42+
ci_appr = "matching",
43+
gps_model = "parametric",
44+
bin_seq = NULL,
45+
trim_quantiles = c(0.25 ,
46+
0.99),
47+
optimized_compile = TRUE,
48+
use_cov_transform = TRUE,
49+
sl_lib = c("m_xgboost"),
50+
params = list(xgb_nrounds=seq(10,60),
51+
xgb_eta=seq(0.04, 0.4, 0.02)),
52+
nthread = 12,
53+
covar_bl_method = "absolute",
54+
covar_bl_trs = 0.1,
55+
covar_bl_trs_type= "maximal",
56+
max_attempt = 10,
57+
matching_fun = "matching_l1",
58+
delta_n = 0.1,
59+
scale = 1)
60+
61+
```
62+
63+
In the previous code, we trimmed data using `trim_quantiles`. This helps to focus on common support range. `m_` in `m_xgboost` stands for modified xgboost library. So we can pass a range of hyperparameter with `xgb_` prefix. Covariate balance has 3 options including method (which only `absolute` has been implemented so far), threshold (`covar_bl_trs`) and threshold type (`covar_bl_trs_type`) which includes `mean`, `median`, and `maximal`. `max_attempt` is the maximum number of attempts to generate pseudo population. `matching_fun` is the matching function (only `matching_l1` has been implemented so far). `delta_n` is the size of caliper and `scale` is a specified scale parameter to control the relative weight that
64+
is attributed to the distance measures of the exposure versus the GPS.
65+
66+
After 6 iterations, a covariate balance is achieved one can run summary to see the summary of the results.
67+
68+
```{r, eval=FALSE}
69+
summary(ps_pop_obj_1)
70+
```
71+
72+
```s
73+
--- CausalGPS pseudo population object summary ---
74+
Pseudo population met the covariate balance requirement: TRUE
75+
Absolute correlation of the original data:
76+
mean: 0.151
77+
median: 0.134
78+
maximal: 0.367
79+
80+
cs_poverty : 0.084
81+
cs_hispanic : 0.134
82+
cs_black : 0.245
83+
cs_ed_below_highschool : 0.234
84+
cs_median_house_value : 0.085
85+
cs_population_density : 0.190
86+
cdc_mean_bmi : 0.047
87+
cdc_pct_nvsmoker : 0.020
88+
gmet_mean_summer_tmmx : 0.254
89+
gmet_mean_summer_rmx : 0.218
90+
gmet_mean_summer_sph : 0.367
91+
cms_female_pct : 0.003
92+
region : 0.078
93+
94+
Absolute correlation of the pseudo population:
95+
mean: 0.060
96+
median: 0.057
97+
maximal: 0.099
98+
99+
cs_poverty : 0.079
100+
cs_hispanic : 0.025
101+
cs_median_house_value : 0.003
102+
cdc_mean_bmi : 0.057
103+
cdc_pct_nvsmoker : 0.035
104+
gmet_mean_summer_tmmx : 0.096
105+
gmet_mean_summer_sph : 0.055
106+
cms_female_pct : 0.072
107+
cs_black : 0.099
108+
cs_ed_below_highschool : 0.089
109+
cs_population_density : 0.087
110+
gmet_mean_summer_rmx : 0.047
111+
region : 0.031
112+
113+
Hyperparameters used for the select population:
114+
xgb_nrounds : 21
115+
xgb_max_depth : 6
116+
xgb_eta : 0.32
117+
xgb_min_child_weight : 1
118+
xgb_verbose : 0
119+
120+
Number of data samples: 2299
121+
Number of iterations: 6
122+
--- *** ---
123+
124+
```
125+
126+
It is important to note that the package ignores any data with missing values. As a result, number of data samples are different from the original data. We can also plot the covariate balance.
127+
128+
```{figure} figures/pdf/example_w_1_covar.pdf
129+
---
130+
height: 600 px
131+
name: Covariate Balance
132+
```
133+
134+
Now, we can conduct the analysis using the pseudo population.
135+
136+
```r
137+
set.seed(168)
138+
erf <- estimate_npmetric_erf(m_Y = ps_pop_obj_1$pseudo_pop$Y,
139+
m_w = ps_pop_obj_1$pseudo_pop$w,
140+
counter_weight = ps_pop_obj_1$pseudo_pop$counter_weight,
141+
bw_seq = seq(0.2,10,0.05),
142+
w_vals = seq(7,13, 0.05),
143+
nthread = 12)
144+
```
145+
146+
The `erf` object contains the estimated exposure-response function. The following plot shows the exposure function.
147+
148+
```r
149+
plot(erf)
150+
```
151+
152+
```{figure} figures/pdf/example_w_1_erf.pdf
153+
154+
---
155+
height: 400 px
156+
name: Exposure Response Function
157+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Research Gallery
2+
3+
This section includes examples from different packages.
4+
5+
```{tableofcontents}
6+
```
7+

docs/blog_posts/R_embarrassingly_parallel.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,22 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
104104
</span>
105105
</p>
106106
<ul class="nav bd-sidenav">
107-
<li class="toctree-l1">
108-
<a class="reference internal" href="../research_gallery/TBD.html">
109-
TBD
107+
<li class="toctree-l1 has-children">
108+
<a class="reference internal" href="../research_gallery/index.html">
109+
Research Gallery
110110
</a>
111+
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
112+
<label for="toctree-checkbox-1">
113+
<i class="fas fa-chevron-down">
114+
</i>
115+
</label>
116+
<ul>
117+
<li class="toctree-l2">
118+
<a class="reference internal" href="../research_gallery/causalgps_example_1.html">
119+
CausalGPS | Example 1
120+
</a>
121+
</li>
122+
</ul>
111123
</li>
112124
</ul>
113125
<p aria-level="2" class="caption" role="heading">
@@ -130,8 +142,8 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
130142
<a class="reference internal" href="../developers_zone/styling_guide.html">
131143
Styling Guide
132144
</a>
133-
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
134-
<label for="toctree-checkbox-1">
145+
<input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>
146+
<label for="toctree-checkbox-2">
135147
<i class="fas fa-chevron-down">
136148
</i>
137149
</label>

docs/blog_posts/R_parLapply_vdi.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,22 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
102102
</span>
103103
</p>
104104
<ul class="nav bd-sidenav">
105-
<li class="toctree-l1">
106-
<a class="reference internal" href="../research_gallery/TBD.html">
107-
TBD
105+
<li class="toctree-l1 has-children">
106+
<a class="reference internal" href="../research_gallery/index.html">
107+
Research Gallery
108108
</a>
109+
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
110+
<label for="toctree-checkbox-1">
111+
<i class="fas fa-chevron-down">
112+
</i>
113+
</label>
114+
<ul>
115+
<li class="toctree-l2">
116+
<a class="reference internal" href="../research_gallery/causalgps_example_1.html">
117+
CausalGPS | Example 1
118+
</a>
119+
</li>
120+
</ul>
109121
</li>
110122
</ul>
111123
<p aria-level="2" class="caption" role="heading">
@@ -128,8 +140,8 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
128140
<a class="reference internal" href="../developers_zone/styling_guide.html">
129141
Styling Guide
130142
</a>
131-
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
132-
<label for="toctree-checkbox-1">
143+
<input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>
144+
<label for="toctree-checkbox-2">
133145
<i class="fas fa-chevron-down">
134146
</i>
135147
</label>

docs/blog_posts/renv_docker.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,22 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
104104
</span>
105105
</p>
106106
<ul class="nav bd-sidenav">
107-
<li class="toctree-l1">
108-
<a class="reference internal" href="../research_gallery/TBD.html">
109-
TBD
107+
<li class="toctree-l1 has-children">
108+
<a class="reference internal" href="../research_gallery/index.html">
109+
Research Gallery
110110
</a>
111+
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
112+
<label for="toctree-checkbox-1">
113+
<i class="fas fa-chevron-down">
114+
</i>
115+
</label>
116+
<ul>
117+
<li class="toctree-l2">
118+
<a class="reference internal" href="../research_gallery/causalgps_example_1.html">
119+
CausalGPS | Example 1
120+
</a>
121+
</li>
122+
</ul>
111123
</li>
112124
</ul>
113125
<p aria-level="2" class="caption" role="heading">
@@ -130,8 +142,8 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
130142
<a class="reference internal" href="../developers_zone/styling_guide.html">
131143
Styling Guide
132144
</a>
133-
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
134-
<label for="toctree-checkbox-1">
145+
<input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>
146+
<label for="toctree-checkbox-2">
135147
<i class="fas fa-chevron-down">
136148
</i>
137149
</label>

docs/blog_posts/use_R_package.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,22 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
103103
</span>
104104
</p>
105105
<ul class="nav bd-sidenav">
106-
<li class="toctree-l1">
107-
<a class="reference internal" href="../research_gallery/TBD.html">
108-
TBD
106+
<li class="toctree-l1 has-children">
107+
<a class="reference internal" href="../research_gallery/index.html">
108+
Research Gallery
109109
</a>
110+
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
111+
<label for="toctree-checkbox-1">
112+
<i class="fas fa-chevron-down">
113+
</i>
114+
</label>
115+
<ul>
116+
<li class="toctree-l2">
117+
<a class="reference internal" href="../research_gallery/causalgps_example_1.html">
118+
CausalGPS | Example 1
119+
</a>
120+
</li>
121+
</ul>
110122
</li>
111123
</ul>
112124
<p aria-level="2" class="caption" role="heading">
@@ -129,8 +141,8 @@ <h1 class="site-logo" id="site-title">NSAPH Software</h1>
129141
<a class="reference internal" href="../developers_zone/styling_guide.html">
130142
Styling Guide
131143
</a>
132-
<input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/>
133-
<label for="toctree-checkbox-1">
144+
<input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/>
145+
<label for="toctree-checkbox-2">
134146
<i class="fas fa-chevron-down">
135147
</i>
136148
</label>

0 commit comments

Comments
 (0)