hw2.sol - Page 1 of 4 Stat209/Ed260 D Rogosa 1/25/09...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Stat209/Ed260 D Rogosa 1/25/09 Solutions Assignment 2. Experiments and Observational Studies. Formulation for causal inference 1. Neyman-Holland-Rubin formulation Create some counter-factual data (following Holland 1988 appendix) 100 (experimental) units > #problem 1 > rho_u = rnorm(100,2,1) #create unit causal effect > mean(rho_u) [1] 1.916993 > var(rho_u) [1] 1.055612 > # that's good > Y_uc = rnorm(100,10,1) #unit score if no treatment > mean(Y_uc) [1] 9.77225 > var(Y_uc) [1] 0.9434952 > Y_ut = Y_uc + rho_u #unit score if treatment > t.test(Y_ut - Y_uc) # paired differences for these 100 units with full counterfactual data One Sample t-test data: Y_ut - Y_uc t = 18.6581, df = 99, p-value < 2.2e-16 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 1.713129 2.120858 sample estimates: mean of x 1.916993 > # so 95% interval includes 2.0 which is the population ACE #create random assignment indicator for obtainable data > G_u = sample(0:1, size = 100, replace = TRUE, prob=c(1/2,1/2)) > G_u [1] 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 1 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 [46] 0 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 0 1 0 1 0 0 1 0 1 [91] 0 0 0 1 0 0 0 1 1 0 > mean(G_u) [1] 0.48 > # so I have 52 controls, 48 experimental units # another way to do this would be to choose a sample without replacement of 50 out of the integers 1:100 and call them controls and the unpicked id's are treatment. That would give 50,50 > Y_utG = Y_uc + G_u*rho_u #create outcome data where G=1 units get rho added > t.test(Y_utG ~G_u) Welch Two Sample t-test data: Y_utG by G_u t = -6.9535, df = 74.517, p-value = 1.166e-09 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -2.465798 -1.367490 sample estimates: mean in group 0 mean in group 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/20/2011 for the course STATS 209 taught by Professor Rogosa,d during the Winter '09 term at Stanford.

Page1 / 4

hw2.sol - Page 1 of 4 Stat209/Ed260 D Rogosa 1/25/09...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online