Announcement

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

  • Scatterplot with overlayed 4th degree polynomial functions in RDD study

    Hello everyone,

    I am working a regression discontinuity study. I have an outcome (y), running variable (x), and a cutoff at x = 0. I would like to create a scatterplot, with two separate functions (before and after the cutoff point) where each function is a 4th degree polynomial of x. I am able to create the plot itself, but the functions does not overlap properly onto the graph. My code thus far as below:

    graph twoway (scatter y x if t >= -15 & t <= 15, title("Earnings in -15≤t≤15") ///
    xtitle("x") ytitle("Mean Earnings") yscale(range(3000 7000)) ///
    name(scatter_plot, replace)) ///
    (function y = 5420 + 19*t + 87*t*t + 914*t*t*t + 13.52*t*t*t*t)

    Any help is greatly appreciated.

  • #2
    Your text seems to imply two quartics, but your code shows only one -- which IIUC looks like an explosion.

    Also, the default x range for twoway function which is [0, 1] doesn't match your ranges which seem to be [-15, 0] and [0, 15].. See the help on the range() option.

    Comment

    Working...
    X