Announcement

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

  • Understanding event study modeling with panel data for never-treated group

    I am working with panel data (which are restricted and thus recreated with simulated data below) at the child-month level across many years. Generally speaking, I'm trying to work on some models in an event study framework where -parent_off- is something that can occur in any given month to a child's parent, and then the outcome is -incident- which is a child-related incident which is also measured each month.

    In my actual data, parent_off is a categorical variable with a few levels; in the case where I'm comparing parent_off=2 to parent_off=3, that modeling is more intuitive to me because they both have valid timing relative to parent_off occurring.

    But the thing I'm trying to make sure I understand is whether and how I can compare children who experience parent_off (at any level, in my simulated data it's a binary variable) to those who never experience parent_off. I'm struggling a bit to understand this because there is inherently no pre-post timing for the "never-treated" group, i.e., children who never experience parent_off.

    The way I currently understand it is that the month fixed effect via -absorb(month)- means that the comparison becomes, e.g., an affected child's probability of incident at rel_post3 relative to month t-1 compared to a never-treated child at rel_post3 within a given year-month. So even though the never-treated child has no pre-post given that they never experience parent_off, the year-month fixed effect means that I'm comparing children's probability of incident within the same year-month. Is that generally correct, or is there something I'm misunderstanding in my data or models? Thanks very much in advance.




    Code:
    clear all
    set more off
    set seed 12345
    
    // Create base dataset of N=5000 children
    local N = 5000    
    local T = 24    
    set obs `N'
    gen child_id = _n
    
    * For half the children, randomly assign an event month 
    gen event_month = .
    replace event_month = round(runiform() * (`T'/2)) + (`T'/2) if child_id <= `N'/2
    
    *  Expand the data so that each child has `T' (24) monthly observations 
    expand `T'
    bysort child_id: gen yr_month = _n
    sort child_id yr_month
    
    * Create predictor var based on event_month
    * For those with an event_month, set parent_off=1 from that month onward
    gen parent_off = 0
    bysort child_id: replace parent_off = 1 if !missing(event_month) & yr_month >= event_month
    
    * Simulate the incident variable such that chance of incident is highest at t=0 and then decreases post-parent_off
    gen incident = .
    replace incident = (runiform() < 0.62) if parent_off == 0
    replace incident = (runiform() < 0.5) if parent_off == 1 & event_month != yr_month 
    replace incident = (runiform() < 0.66) if event_month == yr_month  
    
    // Create event-time vars such that month t-1 is the comparison 
    xtset child_id yr_month
    
    * Relative time variables for treated children 
    gen rel_time = yr_month - event_month if !missing(event_month)
    
    * Pre-event indicator vars (-6 to -2)
    forvalues t = -6/-2 {
        local varname = "rel_pre" + string(abs(`t'))
        gen `varname' = (rel_time == `t')
        replace `varname' = 0 if missing(`varname') & !missing(yr_month)  // Ensure untreated are 0
        replace `varname' = . if !missing(event_month) & (rel_time < -6 | rel_time > 6)  // Restrict for treated
    }
    
    * Post-event indicator vars (0 to +6)
    forvalues t = 0/6 {
        local varname = "rel_post" + string(`t')
        gen `varname' = (rel_time == `t')
        replace `varname' = 0 if missing(`varname') & !missing(yr_month)  // Ensure untreated are 0
        replace `varname' = . if !missing(event_month) & (rel_time < -6 | rel_time > 6)  // Restrict for treated
    }
    
    * Model and plot
    reghdfe incident (rel_pre6-rel_post6), absorb(yr_month) 
    
    coefplot, vertical base keep(rel*) yline(0) ///
        coeflabels( ///
            rel_post0="0" rel_post1="1" rel_post2="2" rel_post3="3" rel_post4="4" rel_post5="5" rel_post6="6" rel_pre6="-6" rel_pre5="-5" rel_pre4="-4" rel_pre3="-3" rel_pre2="-2")

  • #2
    Garrett:
    my comment is only about the last line of your code.
    I would expect something like:
    reghdfe incident (rel_pre6-rel_post6), absorb(child_id yr_month), vce(cluster child_id)
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thanks, Carlo.

      Comment

      Working...
      X