[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Austin Nichols" <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: gsample |

Date |
Thu, 6 Dec 2007 11:47:23 -0500 |

Marcello and Torsten Santavirta-- On a related note, if you are working from the example code in http://pped.org/stata/ciwod.pdf, it reads: ssc install gsample, replace gsample 100, wor gen(pick) levelsof z if pick==1, loc(p) foreach val of local p { cap drop newz g newz=z-'val' bootstrap r(d), reps(1000): discont y znew bootstrap r(d), reps(1000): discont xt znew } but the example given by the poster has levelsof x2co if pick==1, loc(p) and g newz=x2co-'val' which makes no sense--the idea is to pick a random Z to be the new Z0, where we don't expect to find a discontinuity, and see what proportion of the time we would reject the null of no discontinuity. For this, we need to define a new assignment variable newz based on a possible choice of Z, not on X. I should also point out that if you want to put standard error bars around every point, you will need to modify the program to save the local linear regression estimates at every point (to bootstrap) or add an se() option to the -lpoly- command, to use analytic SEs. If you don't want to put standard error bars around every point, you can modify the program to compute the local linear regression estimates at only the cutoff point, which will cut down execution time considerably (esp with 1000 reps on your bootstrap). In the example, where the cutoff is at 0, the current code in -discont- reads loc step=r(max)/50 local N=50+floor(-r(min)/(r(max)/50)) cap set obs 'N' qui g 'z'=(_n-1)*r(max)/50 in 1/51 qui replace 'z'=-(_n-50)*r(max)/50 in 51/'N' (creating a z variable with 50 steps above the cutoff and an appropriate number of steps of equal size below the cutoff, where the local `step' is superfluous and left over from a more elaborate version of the program) but those 5 lines could be usefully rewritten as qui g 'z'=0 in 1 in a parallel version of the program designed not to graph the local linear regressions, but just for bootstrapping the jump, as was pointed out to me last week by Vince Wiggins. The program -rd- on SSC should also be modified to either (1) give SEs at every Z value, or (2) only bootstrap the jump at the cutoff. I will try to modify it in the next few days. On Dec 6, 2007 11:16 AM, Austin Nichols <austinnichols@gmail.com> wrote: > Marcello-- > After installing -moremata-, close Stata and open Stata again. Then > Mata should be able to find everything you need. > > > On Dec 6, 2007 11:02 AM, Marcello Pagano <pagano@hsph.harvard.edu> wrote: > > Hello, > > I would like to use gsample sampling command for cross validation of my > > regression discontinuity as suggested bu Austin Nichols in "Causal > > inference with observational data". > > The idea is to randomly choose placebo cut off points and test > > continuity of the forcing variable and the outcome variable. Now Nichols > > suggests generating random samples from the data. When using the gsample > > command stata suggests that mm_sample() is required asks me to install > > moremata. Having installed moremata the same problems occurs again. What > > could be the problem. I'm using stata 10.0 and my code looks as follows: > > > > ssc install gsample, replace > > gsample 100, wor gen(pick) > > levelsof x2co if pick==1, loc(p) > > foreach val of local p { > > cap drop newz > > g newz=x2co-'val' > > bootstrap r(d), reps(1000): discont y znew > > bootstrap r(d), reps(1000): discont x2co znew } > > > > Does anyone have an idea what goes wrong with using gsample? > > Thank You in advance, > > Torsten Santavirta > > Helsinki School of Economics * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: gsample***From:*Marcello Pagano <pagano@hsph.harvard.edu>

**Re: st: gsample***From:*"Austin Nichols" <austinnichols@gmail.com>

- Prev by Date:
**Re: st: median average deviation** - Next by Date:
**Re: st: Latent class estimation** - Previous by thread:
**Re: st: gsample** - Next by thread:
**st: median average deviation** - Index(es):

© Copyright 1996–2021 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |