# Regression discontinuity

I am analyzing some Stata code for a regression discontinuity analysis. The results of this analysis are presented in table 5 of the Online appendix to “The Effects of a Universal Child Benefit...”. I first need to understand the code below, and then to make a twist (e.g. estimate the regression discontinuity with and without parametric estimation, or any other twist that I can come up with for this data).

Does anyone understand if everything is done already or if there is some possibility to innovate on it?

post is a dummy variable where 1 implies that the person has the treatment. m is month when the baby was born and determines the cutoff point whether or not the person received the treatment.

***********      Employed   *****************************/
xi: reg work2 post i.post|m i.post|m2 age age2 age3 immig primary hsgrad univ sib pleave i.q if m>-10 & m<9, robust
xi: reg work2 post i.post|m age age2 age3 immig primary hsgrad univ sib pleave i.q if m>-7 & m<6, robust
xi: reg work2 post i.post|m age age2 age3 immig primary hsgrad univ sib pleave i.q if m>-5 & m<4, robust
xi: reg work2 post age age2 age3 immig primary hsgrad univ sib pleave i.q if m>-4 & m<3, robust
xi: reg work2 post if m>-3 & m<2, robust
xi: reg work2 post age age2 age3 immig primary hsgrad univ sib pleave i.q if m>-3 & m<2, robust
xi: reg work2 post m m2 age age2 age3 immig primary hsgrad univ sib pleave i.n_month i.q, robust cluster(m)

• In the link you supply there is no table 5. There is a table 3 that 'parallels table 5' - is that what you meant? Sep 18 '14 at 9:10
• What is that you don't understand in the code? It's a series of regressions. If you seek explanation of specific detail of Stata syntax, you need to say which, but that would be off-topic here. Sep 18 '14 at 9:45
• Is it correct? and Could something else be done? are both difficult forms of questions. Sep 18 '14 at 9:47

Here's how I like to play with discontinuities:

Discontinuities can be estimated using hinge functions. Take the simple case of a linear relationship that jumps discontinuously at some point. The model for a straight line is (or ought to be :) familiar (leaving out error):

$$y = \beta_{0} + \beta_{x}x$$

If we want to add a discontinuous jump to this line (i.e. same slope, but with some constant shift at some point), we can instead estimate this model plus the simplest hinge function:

$$y = \beta_{0} + \beta_{x}x + \beta_{\text{c}}\max(\text{sign}(x - \theta),0)$$

Here $\theta$ is the value of $x$ at which the discontinuous jump happens, and $\beta_{\text{c}}$ is the magnitude and direction of that jump. But what do the values of $\max(\text{sign}(x - \theta),0)$ look like? Well they look like $0, 0, 0, 1, 1, 1$ with the $1$s corresponding to $x > \theta$. (There are other ways to specify such a jump rather than using the hinge function as I have done here—e.g. $\beta_{\text{c}}[\text{sign}(x-\theta)+1]/2$—but sit tight and watch what happens to the hinge function with more complicated models.)

How would one estimate this in Stata? By using nl (nonlinear least squares regression):

nl (y = {b_0} + {b_x}*x + {b_c}*max(sign(x-{theta})),0) )


The results of such a model would include four parameter estimates: b_0, b_x, b_c, and theta. If you have a good idea about where the discontinuous jump is, you can tell Stata's algorithm to start looking for values of theta. Here I have done so (only for the first instance of the {theta} parameter) for the value 8.5:

nl (y = {b_0} + {b_x}*x + {b_c}*max(sign(x-{theta=8.5}),0) )


As hinted at earlier, the hinge function is quite versatile. For example, to estimate a line which changes slope without a jump:

$$y = \beta_{0} + \beta_{x}x + \beta_{\text{c}}\max(x - \theta,0)$$

Here values of $\max(x - \theta,0)$ look like $0, 0, 0, 0, 1, 2, 3$ with $>0$ values corresponding to values of $x > \theta$ (assuming $x$ is measured in integer values).

We could likewise model a quadratic effect of $x$ that only begins at $\theta$:

$$y = \beta_{0} + \beta_{x}x + \beta_{\text{c}}\max(x - \theta,0)^2$$

And we can combine these, for example to produce discontinuous jumps, in addition to changes in slope:

$$y = \beta_{0} + \beta_{x}x + \beta_{\text{c}0}\max(\text{sign}(x-\theta),0) + \beta_{\text{c}x}\max(x - \theta,0)$$

And for a discontinuous jump permitting a fully quadratic relationship of $x$:

$$y = \beta_{0} + \beta_{x}x + \beta_{\text{c}0}\max(\text{sign}(x-\theta),0) + \beta_{\text{c}x}\max(x - \theta,0) + \beta_{\text{c}x2}\max(x - \theta,0)^2$$

• Thanks, that looks good. I'm going to delete our exchange (and hopefully, this note eventually); if you want any of the comments restored, just @ me. Jul 8 '15 at 22:40