Graphs in Regression Discontinuity Design in Stata or R

Embed Size (px)

Citation preview

  • 7/21/2019 Graphs in Regression Discontinuity Design in Stata or R

    1/2

    sign up log in tour he lp

    Cross Validated is a question and answer site for people interested in statistics, machine learning, dataanalysis, data mining, and dat a visualizat ion. It 's 100% free, no registrat ion required.

    Take t he 2-minute t our

    Graphs in regression discontinuity design in Stata or R

    (p. 31, 2009) suggest the researcher to present the graphs while doing Regression discontinuity design

    analysis (RDD). They suggest the following procedure:

    Leeand Lemieux

    "...for some bandwidth , and for some number of bins and to the left and right of the cutoff value,

    respectively, the idea is to construct bins ( , ], for + , where "

    h K0 K1

    bk b k+1 k= 1,.. ., K= K0 K1 = c ( k+ 1) h.bk K0

    c=cutoff point orthreshold value of assignment variable

    h=bandwidth orwindow width.

    ...then compare the mean outcomes just to the left and right of the cutoff point..."

    ..in all cases, we also show the fitted values from a quartic regression model estimated separately on each side of the

    cutoff point...(p. 34 of the same paper)

    My question is how do we program that procedure in or for plott ing the graphs of outcome variable against

    assignment variable (with confidence intervals) for the sharp RDD.. A sample example in is mentioned and

    (replace rd with rd_obs) and a sample example in is . However, I think both of these didn't implement thestep 1. Note, that both have the raw data along with the fitted lines in the plots.

    Stata R

    Stata here

    hereR

    here

    Sample graph without confidence variable [Lee and Lemieux,2009]

    Thank you in advance.

    r reg ression data -visualiz ation stata

    edited Feb 15 '13 at 22:38 asked Dec 5 '12 at 13:04

    Metrics

    1,285 4 16

    In response to your flag, a good way to revive your question is to edit it and offer a bounty: This will

    bump your question and get more people interested in it. If you feel this question might be better

    served on Stack Overflow, let us know and we can migrate it for you. chl Feb 9 '13 a t 20:06

    I would like this to be migrated to Stack Overflow. Metrics Feb 12 '13 at 12:10

    1

    Unfortunately, this question is too old to be migrated to Stack Overflow. I believe it belongs on

    Cross Validated but if you want to ask on Stack Overflow (putting emphasis on the

    and providing a minimal ), let me know and I will close it here.

    programming

    aspect reproducible example chl

    Feb 14 '13 a t 10:29

    Graphs in regression discontinuity design in "Stata" or "R" - Cross Validated

    http://stats.stackexchange.com/questions/45184/graphs-in-regression-discontinuity-design-in-stata-or-r

    http://stats.stackexchange.com/questions/tagged/rhttp://stats.stackexchange.com/questions/tagged/regressionhttp://stats.stackexchange.com/questions/tagged/data-visualizationhttp://stats.stackexchange.com/questions/tagged/statahttp://stats.stackexchange.com/posts/45184/revisionshttp://www.stata.com/statalist/archive/2010-11/msg00131.htmlhttp://www.stata.com/statalist/archive/2010-11/msg00131.htmlhttp://stats.stackexchange.com/users/930/chlhttp://stats.stackexchange.com/users/14860/metricshttp://stats.stackexchange.com/users/930/chlhttp://stats.stackexchange.com/users/14860/metricshttp://stats.stackexchange.com/posts/45184/revisionshttp://stats.stackexchange.com/questions/tagged/statahttp://stats.stackexchange.com/questions/tagged/data-visualizationhttp://stats.stackexchange.com/questions/tagged/regressionhttp://stats.stackexchange.com/questions/tagged/rhttp://blog.lib.umn.edu/moor0554/canoemoore/2010/02/regression_discontinuity_gallery_nonparametric.htmlhttp://www.stata.com/statalist/archive/2011-05/msg01640.htmlhttp://www.stata.com/statalist/archive/2010-11/msg00131.htmlhttp://www.nber.org/papers/w14723.pdfhttp://stats.stackexchange.com/questions/45184/graphs-in-regression-discontinuity-design-in-stata-or-rhttp://stats.stackexchange.com/tourhttp://stats.stackexchange.com/tourhttps://stats.stackexchange.com/users/login?returnurl=http%3a%2f%2fstats.stackexchange.com%2fquestions%2f45184%2fgraphs-in-regression-discontinuity-design-in-stata-or-rhttps://stats.stackexchange.com/users/signup?returnurl=http%3a%2f%2fstats.stackexchange.com%2fquestions%2f45184%2fgraphs-in-regression-discontinuity-design-in-stata-or-rhttp://stackexchange.com/
  • 7/21/2019 Graphs in Regression Discontinuity Design in Stata or R

    2/2

    Thanks chi for the bounty Metrics Feb 15 '13 a t 2:54

    You should use . It does everything you need.cmogram Yan Song Apr 7 '13 at 19:49

    1 Answer

    Is this much different from doing two local polynomials of degree 2, one for below the

    threshold and one for above with smooth at points? Here's an example with

    Stata:

    Ki

    usevotex// the election-spending data that comes with rd

    tw

    (scatter lne d,mcolor(gs10)msize(tiny))

    (lpolyci lne d ifd=0,bw(0.05)deg(2)n(100)fcolor(none)),xline(0) legend(off)

    Alternatively, you can just save the lpoly smoothed values and standard errors as

    variables instead of using . Below is the bin, is the smoothed mean, is

    the standard error, and and are the upper and lower limits of the 95%

    Confidence Interval for the smoothed outcome.

    twoway x s se

    ul ll

    lpoly lne d ifd=0,bw(0.05)deg(2)n(100)gen(x1 s1)ci se(se1)

    /* Get the 95% CIs */

    forvalues v=0/1{

    gen ul`v' = s`v' + 1.95*se`v'

    gen ll`v' = s`v' - 1.95*se`v'

    };

    tw

    (line ul0 ll0 s0 x0,lcolor(blue blue blue)lpattern(dash dash solid))

    (line ul1 ll1 s1 x1,lcolor(red red red)lpattern(dash dash solid)),legend(off)

    As you can see, the lines in the first plot are the same as in the second.

    edited Feb 15 '13 at 22:06 answered Feb 14 '13 at20:28

    Dimitriy V. Masterov

    7,455 10 33

    @Dimitry: +1 for the solution. However, I would like to have the mean value for each bin (please run

    the stata example abo ve) rather than the scatter plot showing raw values. CI is great. Metrics

    Feb 15 '13 a t 2:54

    1

    I am not quite sure what you mean. I added coded showing how you get the smoothed means in

    each bin by hand. If that's not what you are looking for, please explain what you have in mind in

    more detail. As far as I can tell, these graphs usually show the raw data and the smoothed means.

    Dimitriy V. Masterov Feb 15 '13 at 21:34

    To quote Lee and Lemieux (p. 31, 2009): "A standard way o f graphing the data is to divide the

    assignment variable(d here) into a number of bins, making sure there are two separate bins on

    each side of the cutoff point (to avoid having treated and untreated observations mixed together in

    the same bin). Then, the average value of the outcome variable can be computed for each bin andgraphed against the mid-points of the bins". So, if there are 50 bins, then we will have only 25 data

    points on the left and right and not all the raw data (e.g, Graph 6(b) of the reference: updated in

    question) Metrics Feb 15 '13 a t 22:39

    1

    Now it's clear! I agree on the kernel. But are you certain it's now not degree 0? That would

    correspond to equally-weighted mean smoothing. Dimitriy V. Masterov Feb 15 '13 a t 22:51

    1 I believe that corresponds to lpoly with a regular kernel and a degree 0 polynomial

    Dimitriy V. Masterov Feb 19 '13 a t 4:35

    Graphs in regression discontinuity design in "Stata" or "R" - Cross Validated

    http://stats.stackexchange.com/questions/45184/graphs-in-regression-discontinuity-design-in-stata-or-r

    http://stats.stackexchange.com/users/7071/dimitriy-v-masterovhttp://stats.stackexchange.com/users/7071/dimitriy-v-masterovhttp://stats.stackexchange.com/users/14860/metricshttp://stats.stackexchange.com/users/7071/dimitriy-v-masterovhttp://stats.stackexchange.com/users/14860/metricshttp://stats.stackexchange.com/users/7071/dimitriy-v-masterovhttp://stats.stackexchange.com/posts/50008/revisionshttp://stats.stackexchange.com/users/24031/yan-songhttp://ideas.repec.org/c/boc/bocode/s457162.htmlhttp://stats.stackexchange.com/users/14860/metrics