Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regression discontinuity plot with clustered standard errors

    Dear Stata Listers,

    I'm using clustered standard errors in my RD design. For my linear split model I cannot figure out how to plot my RD with clustered standard errors displayed to read the discontinuity from the graph.
    Code:
    *linear split regression
    reg y treatment_dummy running_variable treatmentdum_runningvar_interaction, cluster(running_variable)

    This is the twoway scatter I can draw with robust standard errors, but I want to display clustered standard errors.
    Code:
    twoway (scatter y running_variable)                                     ///
        (lfitci y running_variable if treatment_dummy==0, ciplot(rline))    ///
        (lfitci y running_variable if treatment_dummy==1, ciplot(rline)),   ///
        xline(cutoff)

    Also, cmogram and rdplot seem not to offer this option.

    Would you know a way I can plot my regression discontinuity with clustered standard errors?


    Thanks so much for your time and help!
    Sipke Bontekoe

  • #2
    Hello Sipke Bontekoe. I think you mean you want to display the fitted values and CIs from the regression model that uses clustered SEs, and the problem is that -lfitci- does not use those clustered SEs to generate the CIs. I wonder if you can achieve what you want via -margins- and -marginsplot-, with recast(line), recastci(rarea) and addplot() options for the latter. I don't have time to try a toy example right now, but here is a basic example from the documentation that might help steer you in the right direction.

    Code:
    * Example from:
    * https://www.stata.com/manuals/rmarginsplot.pdf
    
    clear
    use https://www.stata-press.com/data/r16/auto
    generate tons = weight/2000
    format tons %6.2f
    separate mpg, by(foreign)
    regress mpg foreign##c.tons##c.tons
    margins, at(tons=(.8(.05)2.4)) over(foreign)
    marginsplot, addplot(scatter mpg0 tons || scatter mpg1 tons) recast(line) noci
    HTH.
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 19.5 (Windows)

    Comment


    • #3
      I found my answer!

      help twoway_lfitci
      And then: estopts() for estopts(cluster(xvar))

      You can add this option into your lfitci specification

      Comment


      • #4
        Thanks for sharing what you found.
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 19.5 (Windows)

        Comment

        Working...
        X