-
-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from joonho112/master
Upload Causal IV case study in education folder
- Loading branch information
Showing
7 changed files
with
4,803 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
4,034 changes: 4,034 additions & 0 deletions
4,034
education/causal_iv_one-sided/case_study_02_IV_one-sided.html
Large diffs are not rendered by default.
Oops, something went wrong.
585 changes: 585 additions & 0 deletions
585
education/causal_iv_one-sided/case_study_02_IV_one-sided.qmd
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@book{imbens2015causal, | ||
title={Causal inference in statistics, social, and biomedical sciences}, | ||
author={Imbens, Guido W and Rubin, Donald B}, | ||
year={2015}, | ||
publisher={Cambridge University Press} | ||
} | ||
|
||
@article{imbens1997bayesian, | ||
title={Bayesian inference for causal effects in randomized experiments with noncompliance}, | ||
author={Imbens, Guido W and Rubin, Donald B}, | ||
journal={The annals of statistics}, | ||
pages={305--327}, | ||
year={1997}, | ||
publisher={JSTOR} | ||
} | ||
|
||
@article{sommer1991estimating, | ||
title={On estimating efficacy from clinical trials}, | ||
author={Sommer, Alfred and Zeger, Scott L}, | ||
journal={Statistics in medicine}, | ||
volume={10}, | ||
number={1}, | ||
pages={45--52}, | ||
year={1991}, | ||
publisher={Wiley Online Library} | ||
} | ||
|
||
@article{feller2016compared, | ||
title={Compared to what? Variation in the impacts of early childhood education by alternative care type}, | ||
author={Feller, Avi and Grindal, Todd and Miratrix, Luke and Page, Lindsay C and others}, | ||
journal={The Annals of Applied Statistics}, | ||
volume={10}, | ||
number={3}, | ||
pages={1245--1285}, | ||
year={2016}, | ||
publisher={Institute of Mathematical Statistics} | ||
} | ||
|
||
@article{page2015principal, | ||
title={Principal stratification: A tool for understanding variation in program effects across endogenous subgroups}, | ||
author={Page, Lindsay C and Feller, Avi and Grindal, Todd and Miratrix, Luke and Somers, Marie-Andree}, | ||
journal={American Journal of Evaluation}, | ||
volume={36}, | ||
number={4}, | ||
pages={514--531}, | ||
year={2015}, | ||
publisher={Sage Publications Sage CA: Los Angeles, CA} | ||
} | ||
|
||
@article{gelman1992inference, | ||
title={Inference from iterative simulation using multiple sequences}, | ||
author={Gelman, Andrew and Rubin, Donald B and others}, | ||
journal={Statistical science}, | ||
volume={7}, | ||
number={4}, | ||
pages={457--472}, | ||
year={1992}, | ||
publisher={Institute of Mathematical Statistics} | ||
} |
62 changes: 62 additions & 0 deletions
62
education/causal_iv_one-sided/stan/cace_with_exclusion.stan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
data { | ||
int<lower=1> N; // Sample size N | ||
array[N] int<lower=0, upper=1> Z; // Treatment assigned Z | ||
array[N] int<lower=0, upper=1> W; // Treatment received W | ||
array[N] int<lower=0, upper=1> Y; // Outcome Y | ||
} | ||
|
||
parameters { | ||
// Population probability of being a complier | ||
real<lower=0, upper=1> pi_c; | ||
|
||
// Probabilities for the binomial outcome distributions | ||
real<lower=0, upper=1> eta_c0; | ||
real<lower=0, upper=1> eta_c1; | ||
real<lower=0, upper=1> eta_n; | ||
} | ||
|
||
model { | ||
// Define local variables for efficiency | ||
real log_pi_c = log(pi_c); | ||
real log1m_pi_c = log1m(pi_c); | ||
|
||
// Prior for Complier probability | ||
// implicit prior: pi_c ~ Unif(0, 1) | ||
|
||
// Priors for outcome model parameters | ||
eta_c0 ~ beta(2, 2); | ||
eta_c1 ~ beta(2, 2); | ||
eta_n ~ beta(2, 2); | ||
|
||
// Likelihood | ||
for(n in 1:N){ | ||
|
||
// Complier (assigned to treatment) | ||
if (Z[n] == 1 && W[n] == 1){ | ||
target += log_pi_c + bernoulli_lpmf(Y[n] | eta_c1) ; | ||
} | ||
|
||
// Never-taker (assigned to treatment) | ||
else if (Z[n] == 1 && W[n] == 0){ | ||
target += log1m_pi_c + bernoulli_lpmf(Y[n] | eta_n); | ||
} | ||
|
||
// Complier or Never-taker (assigned to control) | ||
else if (Z[n] == 0 && W[n] == 0){ | ||
target += log_mix( | ||
pi_c, // Complier probability | ||
bernoulli_lpmf(Y[n] | eta_c0), // Complier | ||
bernoulli_lpmf(Y[n] | eta_n) // Never-taker | ||
); | ||
} | ||
} | ||
} | ||
|
||
generated quantities { | ||
// Superpopulation complier average causal effect (CACE) | ||
// in per-1000 units | ||
real CACE = (eta_c1 - eta_c0) * 10^3; | ||
} | ||
|
||
|
||
|
63 changes: 63 additions & 0 deletions
63
education/causal_iv_one-sided/stan/cace_without_exclusion.stan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
data { | ||
int<lower=1> N; // Sample size N | ||
array[N] int<lower=0, upper=1> Z; // Treatment assigned Z | ||
array[N] int<lower=0, upper=1> W; // Treatment received W | ||
array[N] int<lower=0, upper=1> Y; // Outcome Y | ||
} | ||
|
||
parameters { | ||
// Population probability of being a complier | ||
real<lower=0, upper=1> pi_c; | ||
|
||
// Probabilities for the binomial outcome distributions | ||
real<lower=0, upper=1> eta_c0; | ||
real<lower=0, upper=1> eta_c1; | ||
real<lower=0, upper=1> eta_n0; | ||
real<lower=0, upper=1> eta_n1; | ||
} | ||
|
||
model { | ||
// Define local variables for efficiency | ||
real log_pi_c = log(pi_c); | ||
real log1m_pi_c = log1m(pi_c); | ||
|
||
// Prior for Complier probability | ||
// implicit prior: pi_c ~ Unif(0, 1) | ||
|
||
// Priors for outcome model parameters | ||
eta_c0 ~ beta(2, 2); | ||
eta_c1 ~ beta(2, 2); | ||
eta_n0 ~ beta(2, 2); | ||
eta_n1 ~ beta(2, 2); | ||
|
||
// Likelihood | ||
for(n in 1:N){ | ||
|
||
// Complier (assigned to treatment) | ||
if (Z[n] == 1 && W[n] == 1){ | ||
target += log_pi_c + bernoulli_lpmf(Y[n] | eta_c1) ; | ||
} | ||
|
||
// Never-taker (assigned to treatment) | ||
else if (Z[n] == 1 && W[n] == 0){ | ||
target += log1m_pi_c + bernoulli_lpmf(Y[n] | eta_n1); | ||
} | ||
|
||
// Complier or Never-taker (assigned to control) | ||
else if (Z[n] == 0 && W[n] == 0){ | ||
target += log_mix( | ||
pi_c, // Complier probability | ||
bernoulli_lpmf(Y[n] | eta_c0), // Complier | ||
bernoulli_lpmf(Y[n] | eta_n0) // Never-taker | ||
); | ||
} | ||
} | ||
} | ||
|
||
generated quantities { | ||
// Super-population average causal effects | ||
real CACE = (eta_c1 - eta_c0) * 10^3; | ||
real NACE = (eta_n1 - eta_n0) * 10^3; | ||
} | ||
|
||
|