Announcement

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

  • Scatterplot of change in Y against change in X with a fitted line

    I am working with a replication package and came across the following which I cannot seem to understand (for the ease of convenience I will refer to the dependent variable as Y and explanatory variable as X):

    The paper examines the relationship between Y and X using the following equation:

    Yst = B0 + B1Xst + As + At + est

    where s refers to states, t refers to years, As and At are state and time fixed effects, respectively. The data is a balanced panel with 51 states and 5 years.

    In one of the graphs, the authors show a simple scatter plot of change in Y against change in X along with a fitted line. The adopted method is what I find confusing i.e. the paper plots this graph by:

    1. regressing Y on state and year fixed effects
    Code:
    reg Y st1-st51 y1-y5, robust cluster(state)
    predict dy, residual
    2. regressing X on state and year fixed effects
    Code:
    reg X st1-st51 y1-y5, robust cluster(state)
    predict dx, residual
    3. Finally, regressing dy on dx
    Code:
    reg dy dx, robust cluster(state)
    predict line1
    4. The plot is produced using:
    Code:
    scatter dy dx || line line1 dx, sort
    ​​​​​​​​​​​​​​

    I tried reproducing the graph as follows but it appears they are not the same:
    Code:
    egen id=group(state)
    egen t=group(year)
    tsset id t
    
    gen dY = Y  - l.Y
    gen dX = X - l.X
    
    reg dY dX, robust cluster(state)
    twoway (scatter dY dX) ///
    title("Differences") ///
    xtitle("Change in X") ytitle("Change in Y") legend(off) ///
    (lfit dY dX, lwidth(medthick))
    ​​​​​​​​​​​​​​

    ​​​​​​​Am I missing anything?
    Last edited by Mohsin Javed; 29 Jul 2022, 03:09.
Working...
X