Announcement

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

  • Multilevel models. Error: "repeated time values within lowest-level panels." but data seems ok



    Dear all,

    I have a problem with a dataset.

    I have 8 rats with a continuous outcome measurement (variable "v").
    • There are two baseline values (variables "baseline" and "baseline2")
    • There are 10 time points (variable "time": 30, 60, 90, 120, 150, 180, 210, 240, 270, 300).
    • All of this is for 4 different dosages (variable "dose").
    I want to evaluate the trajectories of the outcome for each dosage and compare them with an interaction term.

    I want to account for the correlation of time points within each rat.
    I want to test multiple variance-covariance structures and then compare the models using the Akaike criterion.


    If I use a model with an independent matrix, such as:

    mixed v i.dose##i.time || rat: time, cov(un) residuals(independent, by(time))

    I have no issues.

    However, if I try to assume that the correlation within each rat is time-dependent (e.g., autoregressive, first order), I get the error message: "repeated time values within lowest-level panels."

    I have checked and I don't see any repeated combinations of variables.

    Where am I going wrong?

    Best regards.

    Gianfrnaco

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte rat float(v baseline baseline2) int time byte dose
    1  98.1  90.1 101.2  30 1
    2 112.2 101.3   120  30 1
    3 114.4   114 107.2  30 1
    4  99.6 104.9 109.4  30 1
    5  87.3 101.7   117  30 1
    6  99.6 110.1 122.3  30 1
    7 104.8 105.7 100.9  30 1
    8  96.3 107.4 109.7  30 1
    1 103.4  90.1 101.2  60 1
    2   106 101.3   120  60 1
    3 116.1   114 107.2  60 1
    4 102.7 104.9 109.4  60 1
    5 116.1 101.7   117  60 1
    6 106.5 110.1 122.3  60 1
    7 105.7 105.7 100.9  60 1
    8 104.3 107.4 109.7  60 1
    1   112  90.1 101.2  90 1
    2   122 101.3   120  90 1
    3   108   114 107.2  90 1
    4   103 104.9 109.4  90 1
    5   116 101.7   117  90 1
    6   114 110.1 122.3  90 1
    7    98 105.7 100.9  90 1
    8   101 107.4 109.7  90 1
    1   119  90.1 101.2 120 1
    2   120 101.3   120 120 1
    3   107   114 107.2 120 1
    4   116 104.9 109.4 120 1
    5   103 101.7   117 120 1
    6    97 110.1 122.3 120 1
    7   106 105.7 100.9 120 1
    8   109 107.4 109.7 120 1
    1 101.8  90.1 101.2 150 1
    2   119 101.3   120 150 1
    3    88   114 107.2 150 1
    4   102 104.9 109.4 150 1
    5   106 101.7   117 150 1
    6   109 110.1 122.3 150 1
    7 103.4 105.7 100.9 150 1
    8 115.9 107.4 109.7 150 1
    1   114  90.1 101.2 180 1
    2   111 101.3   120 180 1
    3    97   114 107.2 180 1
    4   105 104.9 109.4 180 1
    5   111 101.7   117 180 1
    6   109 110.1 122.3 180 1
    7   105 105.7 100.9 180 1
    8   112 107.4 109.7 180 1
    1   105  90.1 101.2 210 1
    2   106 101.3   120 210 1
    3   105   114 107.2 210 1
    4 125.3 104.9 109.4 210 1
    5   107 101.7   117 210 1
    6   106 110.1 122.3 210 1
    7   101 105.7 100.9 210 1
    8  88.5 107.4 109.7 210 1
    1   110  90.1 101.2 240 1
    2    97 101.3   120 240 1
    3    81   114 107.2 240 1
    4   106 104.9 109.4 240 1
    5    92 101.7   117 240 1
    6   109 110.1 122.3 240 1
    7    91 105.7 100.9 240 1
    8   110 107.4 109.7 240 1
    1   101  90.1 101.2 270 1
    2  97.3 101.3   120 270 1
    3    91   114 107.2 270 1
    4   136 104.9 109.4 270 1
    5 103.1 101.7   117 270 1
    6   108 110.1 122.3 270 1
    7   110 105.7 100.9 270 1
    8   107 107.4 109.7 270 1
    1   111  90.1 101.2 300 1
    2    97 101.3   120 300 1
    3   111   114 107.2 300 1
    4   112 104.9 109.4 300 1
    5   113 101.7   117 300 1
    6   103 110.1 122.3 300 1
    7   122 105.7 100.9 300 1
    8   117 107.4 109.7 300 1
    1   110   111 107.2  30 2
    2 112.6    97 110.1  30 2
    3 109.2   111   104  30 2
    4 122.3   112   109  30 2
    5 105.2   113 100.2  30 2
    6 121.2   103  99.5  30 2
    7   106   122 116.4  30 2
    8 100.2   117   114  30 2
    1  82.2   111 107.2  60 2
    2  80.7    97 110.1  60 2
    3  84.3   111   104  60 2
    4 81.15   112   109  60 2
    5  85.8   113 100.2  60 2
    6    88   103  99.5  60 2
    7  90.3   122 116.4  60 2
    8 103.4   117   114  60 2
    1    55   111 107.2  90 2
    2  63.1    97 110.1  90 2
    3  51.2   111   104  90 2
    4  59.8   112   109  90 2
    end

  • #2
    However, if I try to assume that the correlation within each rat is time-dependent (e.g., autoregressive, first order), I get the error message: "repeated time values within lowest-level panels."
    Yes, you are here asking Stata to do the impossible. First order autoregressive means that Stata has to estimate correlation between residuals at successive time points. But, even in your example data, let alone your full data set, for each rat (the only upper level specified in your model) you have two observations at the same time. And Stata cannot tell which of those two observations at time 1 should be paired up for this purpose with which of those two observations at time 2. Now, you know, and I can perceive that your intent is that they should be paired up when they have the same dose. But you didn't tell Stata about that, and as far as Stata is concerned, dose is irrelevant to this. To tell Stata that this is your intent, you need to add dose as another level in the model.

    Comment


    • #3
      Dear Clyde Schechter , thank you for your help.

      I tried it this way: mixed v i.dose##i.time || rat : || dose: , residuals(ar 1, t(time))
      The command runs, although very slowly, and eventually it will give me an output.

      However, since "rat" and "dose" are crossed factors, I also tried running the model with the script:

      mixed v i.dose##i.time || _all: R.rat || dose: , residuals(ar 1, t(time)).

      In this case, however, it gives me "repeated time values within lowest-level panels".

      This is not clear to me because the two higher levels have been specified.
      Do you have any ideas about this? Thank you again enormously.

      Gianfranco

      Comment


      • #4
        Yes, I see. That's because in a crossed-effects model, there isn't a unique lowest level, so Stata doesn't know what to make of this.

        I think what you will have to do is:
        Code:
        egen stratum = group(rat dose)
        and then use stratum as your second level in the model. This is not perfect, however, because now the random coefficient for time will be at that level, rather than at the rat level.

        I'm not sure that the exact model you would like can be done at all. Maybe somebody else sees a solution and will comment.

        Comment


        • #5
          Dear Clyde Schechter , I take advantage of your kindness and thank you in advance.
          As you understand, I'm practicing mixed models in STATA.

          About the example above, I told you that the rats are crossed in dose and time (I always use the same 8 rats).

          But if instead I used for each dose, 8 different rats (each with their own "id") and I measured the outcome (variable "v") at each timepoint, how would the model be specified?

          Summing up:

          I have 4 different dosages (variable "dose") of a drug.
          There are 10 time points (variable "time": 30, 60, 90, 120, 150, 180, 210, 240, 270, 300).
          For each dosage I use 8 different rats (32 rats in total), to which I measure the drug at each timepoint.

          The structure at that point would be:
          4 doses crossed with 10 timepoints.
          And the rats? Would they be nested?

          I don't understand at this point what the data structure would look like and how to specify it in STATA.


          Thanks for any feedback, I hope I'm not boring you.
          Gianfranco

          Comment


          • #6
            Originally posted by Gianfranco Di Gennaro View Post
            However, since "rat" and "dose" are crossed factors. . .
            No, they're not. There's nothing exchangeable about the four doses. Dose is a fixed effect.

            If you want to distinguish the sets of time points within each of the combinations of rat and dose, then you would form the rat × dose interaction term, which will be another random effect. Because you want to account for any variance in the rat × dose (random) interaction in terms of correlated residuals, you would use the noconstant option for that second level:
            Code:
            mixed v i.dose##i.time || rat: || dose: , noconstant residuals(ar 1, t(time))
            And it ought to converge sooner..

            The model that you show in your first post above
            Code:
            mixed v i.dose##i.time || rat: time, cov(un) residuals(independent, by(time))
            is even more misspecified. Instead, use the analogous specification as for the AR(1):
            Code:
            mixed v i.dose##i.tim || rat: || dose: , noconstant residuals(unstructured, t(time))
            Originally posted by Gianfranco Di Gennaro View Post
            . . . if instead I used for each dose, 8 different rats each with their own "id") and I measured the outcome (variable "v") at each timepoint, how would the model be specified?
            Code:
            mixed v i.dose##i.time || rat: , noconstant residuals(<whichever>, t(time))

            Comment


            • #7
              A thousand thanks.
              I have a very last question. Then I will stop taking your precious time.

              If I wanted to capture nonlinearity over time and used 3 spline knots (3 because I only have 11 timepoints, and I guess using more knots would overparametrize the model), would it still make sense to model the residuals with "noconstant residuals(<whichever>, t(time))"?

              It would be something like:
              mkspline timepoint=time, cubic displayknots nknots(3)
              mixed v i.dose##i.timepoint* || rat: , noconstant residuals(<whichever>, t(time))

              Thanks again for your support.
              Gianfranco

              Comment


              • #8
                Originally posted by Gianfranco Di Gennaro View Post
                If I wanted to capture nonlinearity over time . . .
                Including the time predictor as a factor variable does that. You don't need to go any further.

                It would be something like:
                mkspline timepoint=time, cubic displayknots nknots(3)
                mixed v i.dose##i.timepoint* || rat: , noconstant residuals(<whichever>, t(time))
                It would be better I think to include the splines as continuous:
                Code:
                mixed v i.dose##c.timepoint* || rat:
                If it were me, I would stick with time as a factor variable. It makes it a little bit easier to use margins when you go to explore the timecourse of the dose-response profile.

                And I'd probably forgo the structured residuals: AR(1) for biology I think is usually not close enough to the truth to be useful, and with so many time points a completely unstructured covariance matrix with such a small sample might prove troublesome in the model-fitting process.

                Comment


                • #9
                  "If it were me, I would stick with time as a factor variable. It makes it a little bit easier to use margins when you go to explore the timecourse of the dose-response profile"

                  Thanks, but if I keep time as fixed, I have a lot of parameters to estimate (I have both main effects and interactions with dose).

                  Comment

                  Working...
                  X