Announcement

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

  • Having to explicitly declare autocorrelation in mixed?

    Hi Everyone,

    I'm learning to use mixed models with longitudinal data but I am unclear with what exactly the random effect portion of the Stata mixed command is doing.

    The fixed portion of the command is looking at an interaction between the experimental condition and which period of data collection they were in (T1, T2, T3, T4).

    The random portion is including participant id and allows the slope for period to change across each respondent.

    Code:
    mixed y condition##period || id:period, vce(cluster id) cov(unstructured)
    I understand that autocorrelation needs to be avoided, and I know that y (@T1) correlates with y (@T2) , y (@T2) correlates with y (@T3), etc.

    I want to adjust for this issue, but I <think> that this is being addressed by identifying id in the 'id:' portion of the command. Is this correct?

    Thanks!

    David.
    Last edited by David Speed; 25 Aug 2022, 08:06.

  • #2
    I understand that autocorrelation needs to be avoided, and I know that y (@T1) correlates with y (@T2) , y (@T2) correlates with y (@T3), etc.
    True, true, and unrelated.

    Autocorrelation does not refer to correlation of the values of y within subject at different time periods. That is automatically dealt with by the random intercepts at the id: level. Autocorrelation is different: that is when the residuals for observations on the same person at different time period are correlated. If you believe that is a problem in your situation, you can model it by adding the -residuals(ar(#))- option to your -mixed- command, replacing # with the actual order of the autoregressive structure.

    By the way, I want to point out a subtle error in your -mixed- command. In the fixed-effects portion, you have specified condition##period. By default, Stata treats condition and period as discrete variables (which I suppose is appropriate in most situations like this.) But when you then write -|| id: period-, you are telling Stata to treat period as a continuous variable. This inconsistency will not, I think, be picked up by Stata as an error, but it is a mis-specified model. For a proper model, you have to commit to period being either continuous or discrete. If it is discrete then you need to change the random portion to -|| id: i.period-. If it is continuous, you need to change the fixed portion of the model to condition##c.period. For whatever reason, when StataCorp implemented factor-variable notation, they chose continuous to be the default in free-standing variables, but discrete to be the default in interaction terms. So you have to be careful when you have the same variable both freestanding and in an interaction term in the same model to keep them consistent with each other.

    Comment


    • #3
      Hi Clyde,

      Ahhh, thank-you for the clarification on this! I certainly wouldn't have noticed the difference in the factor and continuous treatment of the period variable, and I've updated my syntax to reflect this.

      A follow-up question:

      It looks as though--after looking at the confidence intervals for different AR values--that AR 1 is statistically significant (its CIs do not capture 0) but higher AR values are not statistically significant. However, because I'm using the vce(cluster id) option I cannot use the lrtest option to formally compare the non-AR model with the AR model (or compare AR 1 vs. AR 2, et.). Is there a test that does allow me to compare models with robust errors? I'd rather not drop the robust error option and I don't mind skipping the lrtest if looking at the AR confidence intervals are sufficiently informative.

      Cheers,

      David.

      Comment


      • #4
        I am not aware of any other way to do this while maintaining cluster robust errors. That said, I do not usually work with time series sufficiently fine-grained as to involve consideration of autoregressive effects, so my knowledge in this area is very limited. You should not take my lack of awareness of anything in this area as strong evidence that there is no such thing. Hopefully someone following this thread who knows more about this area will respond.

        Comment


        • #5
          Thank-you so much for your time Clyde, it has been quite helpful!

          Comment

          Working...
          X