Announcement

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

  • Multilevel model (mixed command) with clustered, repeated-measures data

    Hello Statalist,

    I am building a multilevel model to test whether an environmental exposure is linked with individual's weight/change in weight over time.

    My dataset comprises 3000 individuals nested within 120 community clusters (clusterid) who were measured at five time points (time). The outcome variable is weight. I need to control for two fixed covariates measured at the individual level (inc and mat_ill). The independent variable of interest is measured at the cluster level (env_exp), and I also need to include two fixed cluster-level covariates (alloc and dens).

    Is the following code correct for measuring the effects of env_exp and its interaction with time on weight?

    mixed weight inc mat_ill alloc dens env_exp time env_exp#time || clusterid: time

    Many thanks!

  • #2
    No. The variable time is inconsistently handled in that code. It will probably run without throwing error messages, but the results will be nonsense.

    When you use the syntax env_exp#time you are implicitly treating time as a discrete variable. Otherwise said, Stata will respond to that by creating virtual indicator ("dummy") variables corresponding to four of the five time periods. But when you then write -clustered: time- you are asking Stata to treat time as a continuous variable. The results will be useless.

    So first you need to decide whether you want to treat time as a continuous variable or a discrete one. If the former:
    Code:
    mixed weight inc mat_ill alloc dens env_exp##c.time || clustereid: time
    will give you what you are looking for.

    If you want time to be discrete, then, unfortunately, you cannot use factor-variable notation because the random effects parts of the multi-level model commands don't support it. This is one of those situations for dragging out the old -xi- command:

    Code:
    xi: mixed weight inc mat_ill alloc dens i.env_exp*i.time || clustereid: i.time

    Comment


    • #3
      Thank you for your very clear and helpful reply Clyde!

      Comment


      • #4
        I have a couple of comments, based upon my reading of your original post.

        First, it seems that you have a three-level hierarchical model. If I read you correctly—"3000 individuals . . . who were measured at five time points"—you have individual time-point measurements as the first (residual) level, people (study participants) at the second level and communities at the highest level. And the time random effect is at the second (person) level. So, the model would be something like
        Code:
        mixed body_weight <other stuff> i.treatment##c.time || community_id: || person_id: time
        Is that more like what you've got?

        Second, if you're going to treat time as categories, as in Clyde's second syntax, then make sure that the five time points are the same time (calendar date) among the 3000 study participants, so that whatever unique features of the moment that generate the level of the random effect for each category of time point are shared among all participants.

        Economists occasionally model time as a categorical random effect, and I'm told that this is in order to account for the occurrence of financial shocks, political events, weather catastrophes, natural disasters and whatnot that are felt throughout the economy and so are temporally shared by all clusters at that moment.

        Otherwise, if the enrollment in the study is staggered (each time point is not at the same calendar date or substantively defined date range for all participants, but rather is, say, an elapsed interval since enrollment), then you don't really have uniqueness to that time point, which is necessary to realize a given level of that random effect. In that case, you're better off with the kind of model given by Clyde's first syntax, that is, treat time as continuous with the slope a characteristic of the person, and not of the moment.

        Comment


        • #5
          Many thanks for following up on this Joseph. You are right about the three level hierarchical structure. I am new to using Stata for mixed models and struggled to find examples/resources beyond a two level structure so apologies for silly mistakes! Your code example makes sense in terms of specifying the levels.

          Enrollment was staggered and follow-up time points were based on enrolment date for each participant so I am going to treat time as a continuous variable to account for this.

          Comment

          Working...
          X