Announcement

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

  • ITSA - segmented regression in Stata

    Hi all and Ariel Linden

    I was going through the UCLA page on how to do peicewise regression in Stata https://stats.idre.ucla.edu/stata/fa...sion-in-stata/

    I'm interested in including an intervention and time interaction term, but not sure how. The itsa command by Ariel Linden says the model for one group under study is:

    Y_t = Beta_0 + Beta_1(T) + Beta_2(X_t) + Beta_3(TX_t)

    Here Y_t is the aggregated outcome variable measured at each equally spaced time point t, T is the time since the start of the study, X_t is a dummy (indicator) variable representing the intervention (preintervention periods 0, otherwise 1), and TX_t is an interaction term


    How do I manually fit this regression equation above (i.e., incorporating the intervention and time interaction) with the below code without using the itsa command?

    Code:
    use https://stats.idre.ucla.edu/stat/stata/faq/talk, clear
     
    generate age1 = (age - 14)  
    replace  age1 = 0 if age >= 14
    generate age2 = (age - 14)  
    replace  age2 = 0 if age < 14  
    
    generate int1 = 1
    replace  int1 = 0 if age >= 14
    generate int2 = 1
    replace  int2 = 0 if age < 14  
    
    regress talk int1 int2 age1 age2, hascons  
    
    predict yhat  
    twoway (scatter talk age)  (line yhat age if age <14, sort) (line yhat age if age >=14, sort), xline(14)
    Any tips will be appreciated.

    Thank you
    Last edited by Madu Abuchi; 09 Jan 2020, 06:36.

  • #2
    just run the ITSA command and then use the generated variables _t and _X and _XT in your regression model

    Comment

    Working...
    X