Announcement

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

  • xtmixed models - panel data with two variables across time

    Dear all,

    Hope you can help me with this one. I have panel data across 30 individuals. This individuals were assessed across time 6 times for two different variables (e.g. cholesterol and glicemia). I would like to know if glicemia is varying across time and at the same time across cholesterol, i.e. if glicemia is increasing or decreasing differently if cholesterol is increasing or decreasing across time. AS an example of a possible conclusion for the analysis I aim to perform would be " People who increase cholesterol level across time tend to increase glicemia". My gut tells me that xtmixed fits the purpose but I am not sure what syntax is fitted here. Already checked the xtmixed stata manual and there is not real a model that really helps solving me this issue. Can you please help me. Below is the data.

    Thank you in advance,

    Gonçalo Cotovio

    Code:
    id    time    colesterol    glicemia
    1    1    15    1.07
    1    2    16    1.17
    1    3    15    1.23
    1    4    10    1.18
    1    5    20    1.22
    1    6        1.24
    2    1    40.5    .96
    2    2    44    .96
    2    3    41    .94
    2    4    38    1
    2    5    39    1.02
    2    6    26    1
    3    1    30    1.04
    3    2    23    1.08
    3    3    22    1.11
    3    4    23    1.12
    3    5    27    1.12
    3    6    19    1.17
    4    1    42.5    1.07
    4    2    34    1.08
    4    3    32    1.13
    4    4    15    1.11
    4    5    23    1.07
    4    6    14    1.07
    5    1    25    .96
    5    2    25    1.01
    5    3    32    1
    5    4    27    .97
    5    5    23    .97
    5    6    30    .99
    6    1    28    .95
    6    2    22    .99
    6    3    20    .95
    6    4    27    .95
    6    5    23    .97
    6    6    28    .98
    7    1    15    1.06
    7    2    14    1.03
    7    3    11    1.05
    7    4    8    1.03
    7    5    8    1.04
    7    6    10    1.02
    8    1    31    1
    8    2    28    1.01
    8    3    31    .97
    8    4    14    .98
    8    5    14    .97
    8    6    7    .97
    9    1    27    .99
    9    2    23    1
    9    3    14    1
    9    4    16    1.01
    9    5    12    1.01
    9    6    10    1.01
    10    1    13.5    1.02
    10    2    13    1.03
    10    3    12    1
    10    4    11    1.04
    10    5    10    1.03
    10    6    8    1.02
    11    1    20.5    1.06
    11    2    20    1.14
    11    3    20    1.12
    11    4    20    1.13
    11    5    22    1.11
    11    6    12    1.13
    12    1    10.5    .99
    12    2    12    .96
    12    3    14    .95
    12    4    17    .97
    12    5    19    .94
    12    6    17    .95
    13    1    39    1.03
    13    2    37    1.11
    13    3    34    1.13
    13    4    26    1.12
    13    5    19    1.1
    13    6    23    1.11
    14    1    29.5    .96
    14    2    23    .98
    14    3    23    .99
    14    4    21    .97
    14    5    10    1
    14    6    6    .99
    15    1    21.5    .98
    15    2    15    .96
    15    3    15    .96
    15    4    16    .97
    15    5    14    .96
    15    6    17    .95
    16    1    39    1.05
    16    2    39    1.07
    16    3    40    1.07
    16    4    36    1.06
    16    5    27    1.06
    16    6    24    1.05
    17    1    22.5    1.01
    17    2    18    1.02
    17    3    17    1.03
    17    4    16    1.04
    17    5    18    1.04
    17    6    4    1.02
    18    1    35    1.05
    18    2    30    1.09
    18    3    29    1.05
    18    4    29    1.07
    18    5    22    1.08
    18    6    25    1.03
    19    1    12.5    1
    19    2        .99
    19    3    13    1.04
    19    4    11.5    .98
    19    5    9    1.04
    19    6    9    1.05
    20    1    14    1
    20    2    2    .96
    20    3    11    1.01
    20    4    5    .98
    20    5        .95
    20    6    11    1.02
    21    1    37.5    1.01
    21    2    44    1.04
    21    3    31    .96
    21    4        1
    21    5    41    .98
    21    6    42.5    .99
    22    1    19.5    .92
    22    2    25    .91
    22    3    25    .9
    22    4    7.5    .88
    22    5    13    .89
    22    6    14    .88
    23    1    30    .97
    23    2    27    1.01
    23    3    19    1.02
    23    4    21    1.01
    23    5    13    1.01
    23    6    14    1.02
    24    1    28    .96
    24    2    22    .95
    24    3    27    .96
    24    4    22    .92
    24    5    17    .96
    24    6    23    .95
    25    1    27    .96
    25    2    16    .98
    25    3    18    1.01
    25    4    17    1
    25    5    19    1
    25    6    18.5    .94
    26    1    36.5    1
    26    2        1
    26    3    45    1
    26    4        1
    26    5    25.5    1
    26    6    13    .99
    27    1    38    1.03
    27    2    33    1.04
    27    3    35    1.1
    27    4    35    1.05
    27    5    34    1
    27    6    34    1.03
    28    1    37    .92
    28    2    34    .92
    28    3    36    .91
    28    4    30    .9
    28    5    26    .91
    28    6    36    .91
    29    1    22.5    .97
    29    2    20    .94
    29    3    19    .97
    29    4    14    .96
    29    5    18    .93
    29    6    14    .98
    30    1    46.5    1.01
    30    2    45    1.02
    30    3    39    1.03
    30    4    47    1.03
    30    5    51.5    1.09
    30    6    45    1.06

  • #2
    Maybe something like
    Code:
    bysort id (time): generate double delta_col = colesterol - colesterol[_n-1] if _n > 1
    mixed glicemia c.delta_col || id:
    or
    Code:
    tsset id time
    mixed glicemia D.colesterol || id:
    You have a few patients with gaps in the serial observations, and so the two methods won't give identical results. The first will retain temporal trends even in the presence of gaps, and might be a little better at addressing your question.

    Comment


    • #3
      Not sure if that fits exactly the goal. Nevertheless, I ll try it. I would like to add that I'd tried the code below but I am unsure if this is accounting for variability across time for cholesterol, which is crucial to my question.
      Thank you in advance for your help.

      Code:
      xtmixed glicemia c.timee##c.colesterol || id: time, cov(unstr) variance reml

      Comment


      • #4
        From what I understand of your question, and from the fact that you have only a handful of patients, you might be better off treating both glycemia and cholesterol measurements as outcome variables, and examining the data individually by patient, i.e., address the question graphically.

        Maybe something like
        Code:
        sort id time
        
        quietly levelsof id, local(ids)
        set more on
        foreach id of local ids {
            graph twoway ///
                line colesterol time if id == `id', lcolor(red) yaxis(1) || ///
                line glicemia time if id == `id', lcolor(blue) yaxis(2) ///
                    ylabel( , angle(horizontal) nogrid axis(1)) ///
                    ylabel( , angle(horizontal) nogrid axis(2)) ///
                        title(id = `id', ring(0) position(6)) legend(off)
        
            more
        }
        It looks as if there isn't a strong relationship between them, at least over the time interval that you're using.

        Comment


        • #5
          Thank you for your answer but this wont be possible. I only copy data from part of the database. In fact I have more that 300 patients. Let me try to put my question in other words:
          So in this study I have assessed 2 variables (e.g. Cholesterol and Glycemia) at 6 different time points (weekly) for each individual. Not every time point has both assessments (there are some missing values due to loss to follow-up or to incorrect completion of the database).

          - My first question was:
          Is glicemia decreasing (changing) across time?
          This was the code:
          Code:
          xtset id time
          xtmixed glicemia c.time || id: time, cov(unstr) variance reml
          - Then I thought:
          Is glycemia decreasing (changing) differently across time if cholesterol is also decreasing (changing) across time?
          Doing the code below does not seem right to me hence my issue finding the proper way to answer this question:
          Code:
          xtset id time
          xtmixed glicemia c.time##c.colesterol || id: time, cov(unstr) variance reml
          Please let me know if further details are needed. Thank you in advance for your help in this tricky question.

          Comment


          • #6
            Originally posted by Goncalo Cotovio View Post
            My first question was:
            Is glicemia decreasing (changing) across time?
            . . . Then I thought:
            Is glycemia decreasing (changing) differently across time if cholesterol is also decreasing (changing) across time?
            You didn't mention that you had 300 patients' data before, but it sounds as if your interest is exploratory, and I still recommend doing that graphically as opposed to some kind of involved modelling at this stage. You can randomly select a couple of dozen patients' data for graphical exploration in a manner like I show above. If the relationship is strong enough to make a difference, it should be fairly apparent.

            I don't usually advocate discretization of continuous data, but your second question poses a conditional outcome, and you would probably be better off making an effort to more formally define what you mean by the condition, if cholesterol is decreasing over time. After you've done that, you can segregate the patients algorithmically (or manually) into those whose cholesterol is decreasing and those whose cholesterol is not decreasing, or even into three groups: decreasing, increasing and not clearly either.

            You can then either eyeball the graphs in each group and make a qualitative judgment or you can go ahead with some kind of modeling. If the latter, then the sign of the regression coefficient on the categorical indicator variable × time interaction term will give you the direction of temporal change in the glycemia measure.

            Comment

            Working...
            X