Announcement

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

  • Binscatter with a quadratic fit and controls

    Hi,

    I would like to create a binned scatterplot with a quadratic fit and controls for several variables.

    Here is my data:

    Code:
    local obs 200
    set obs `obs'
    
    gen tenure=runiform()*20
    gen e=rnormal(0,30)
    gen f = 1 in 1/100
    replace f = 0 in 101/200
    gen tenure2 = tenure^2
    gen wage = 5 + tenure+ 2*tenure2 + e if f == 0
    replace wage = 20 + tenure + 2*tenure2 + e if f == 1
    I do the following to create a binned scatterplot using the program -binscatter-:
    Code:
    binscatter wage tenure, line(qfit) controls(f) reportreg
    The reported coefficients from "reportreg" are different from the following regression:
    Code:
    reg wage tenure tenure2 f
    According to the help documentation: "Linear or quadratic fit lines are estimated using the underlying data, not the binned scatter points. When combined with controls() or absorb(), the fit line is estimated after the variables have been residualized."

    I have 2 questions:

    1) Is there a method to create a binscatter plot that uses the coefficients from the regression? Combining the scatterplot from -binscatter- with a function based on the regression results does not seem to work. The line does not fit well.

    2) How do you reconcile the differences from the binscatter "reportreg" results and the regression results? Is there one that is more obviously correct than the other?

    Thanks so much!

Working...
X