Announcement

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

  • Testing for effect modification in time series analyses

    I am running a single group interupted time series analyses to test the effect of an intervention. I have physical activity data before and after the intervention. I have successfully run this with XTITSA. I have looked at the effect for different strata across certain variables (e.g. age strata).
    From examining the results, it looks like age is an effect modifier but I want to do a formal test to confirm this (either LRT or Wald) but am finding this challenging and am hoping for help with the code.

    I am able to test with Wald but this is just for difference between the strata (e.g. a reference strata and another) as follows:
    The example below shows gender:
    **Run ITSA**
    xtitsa activeminutes i.gender , single trperiod(0) vce(robust) posttrend figure replace
    **Run with gender as interaction term**
    xtgee activeminutes _t _x0##i.gender _x_t0, vce(robust)
    **comparison between gender and intervention effect**
    margins _x0#gender, pwcompare(effects) mcompare(sidak)

    I'd like to test whether difference between the model with and without the interaction term (ie is it an effect modifier) and wondered if anyone can help with this. I tried to run the original model, store the estimates, run the model with the interaction, store the new estimates and then the lrtest command, but this does not work (see below).

    **Run ITSA**
    xtitsa activeminutes i.gender , single trperiod(0) vce(robust) posttrend figure replace
    **Store estimate**
    estimates store original
    **Run with gender as interaction term**
    xtgee activeminutes _t _x0##i.gender _x_t0, vce(robust)
    **Store estimate**
    estimates store interaction
    **LRT**
    lrtest original interaction, stats

    Does anyone have any thoughts on how to do this?

  • #2
    Just to add, with lrtest I get the error "LR test likely invalid for models with robust VCE". I then added force. Then I get the error "model original2 does not contain scalar e(ll)"

    I think achieve the above using Wald test with the following code:
    **Run ITSA**
    xtitsa activeminutes i.gender , single trperiod(0) vce(robust) posttrend figure replace
    **Run with gender as interaction term**
    xtgee activeminutes _t _x0##i.gender _x_t0, vce(robust)
    **Wald test whether gender is effect modifier**
    margins _x0#ngen, contrast

    Is this correct?
    Last edited by dharani yerrakalva; 23 May 2025, 07:56.

    Comment

    Working...
    X