Announcement

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

  • Time-varying covariate and predictor interaction in linear mixed

    Hello Everyone,

    I am trying to write code for an interaction between a binary predictors and time-varying covariate within a linear mixed model.

    Research question: Whether treatment differently reduces weight according to vitamin D supplementation level

    In this panel dataset, each participant visited the clinic a minimum of 10 times, and measurement were taken at each visit.

    Treatment has two levels, moderate or intense

    Weight change is the dependent variable

    Vitamin D supplementation is a time-varying covariate. This is a continuous variable (but can be categorized into four levels if this helps with interpretation of the results)

    Here is my code:

    HTML Code:
    mixed weightch i.treat c.vitamindose c.visits || id: c.visits, covariance (uns) variance reml  
    Next step:
    How to include the interaction term between the binary predictor and the time-varying covariate in the code.


    Your help will be much appreciated.

    Thank you,
    Al Bothwell

  • #2
    You seem to know about factor-variable notation already, so perhaps there is a subtlety in your question that I am missing. But it looks to me like it's just:

    Code:
    mixed weightch i.treat##c.vitamindose c.visits || id: c.visits, covariance (uns) variance reml
    Added: Categorizing a continuous variable usually just throws away information and is rarely helpful.

    Comment


    • #3
      Thanks for your comments Clyde. I will use the continuous variable rather than categorizing it.

      I failed to articulate my question probably so I will restate. This is longitudinal patient data collected over a five year time period. The research question is whether the effect of treatment (treatment or control) on weight change is moderated by the level of vitamin dose. Vitamin dose for each patient did not remain the same. Some patients reduced the units of vitamins over time while others increased the units of vitamins taken. So I am thinking that I need to specify vitamin dose both as a fixed and random effect. The time variable is represented by "visits". Here is my code and result. Is this an adequate approach to examine the research question?

      Code:
       mixed weightch i.treat##c.vitamindose_c ib2.sex ib2.race_group c.visits || id: c.visits, cov (unstructured) || c.vitamindose_c:, variance reml
      PHP Code:
      Performing EM optimization:

      Performing gradient-based optimization:

      Iteration 0:   log restricted-likelihood = -8489.5505  
      Iteration 1
      :   log restricted-likelihood = -8488.4947  
      Iteration 2
      :   log restricted-likelihood = -8488.4808  
      Iteration 3
      :   log restricted-likelihood = -8488.4808  

      Computing standard errors
      :

      Mixed-effects REML regression                   Number of obs     =      2,292

      -------------------------------------------------------------
                      |     
      Noof       Observations per Group
       Group Variable 
      |     Groups    Minimum    Average    Maximum
      ----------------+--------------------------------------------
                   
      id |        305          3        7.5         31
         vitamindose_c 
      |        670          1        3.4         22
      -------------------------------------------------------------

                                                      
      Wald chi2(6)      =      92.50
      Log restricted
      -likelihood = -8488.4808          Prob chi2       =     0.0000

      ---------------------------------------------------------------------------------------
                   
      weightch |      Coef.   StdErr.      z    P>|z|     [95ConfInterval]
      ----------------------+----------------------------------------------------------------
                      
      treat |
                   
      Control  |          0  (base)
                 
      Treatment  |  -1.669402   1.099075    -1.52   0.129     -3.82355    .4847455
                            
      |
              
      vitamindose_c |  -1.903029   .9713769    -1.96   0.050    -3.806893    .0008349
                            
      |
      treat#c.vitamindose_c |
                 
      Treatment  |  -2.323661    1.11186    -2.09   0.037    -4.502867   -.1444543
                            
      |
                        
      sex |
                    
      Female  |    .222921    .986168     0.23   0.821    -1.709933    2.155775
                      Male  
      |          0  (base)
                            |
                 
      race_group |
                 
      Non-white  |  -1.026078   1.446138    -0.71   0.478    -3.860455      1.8083
                     White  
      |          0  (base)
                            |
                     
      visits |   -.300375   .1006971    -2.98   0.003    -.4977378   -.1030123
                      _cons 
      |   1.818451   1.691374     1.08   0.282    -1.496581    5.133483
      ---------------------------------------------------------------------------------------

      ------------------------------------------------------------------------------
        
      Random-effects Parameters  |   Estimate   StdErr.     [95ConfInterval]
      -----------------------------+------------------------------------------------
      idUnstructured             |
                       var(
      visits) |   .7126767   .1990338      .4122608    1.232007
                        
      var(_cons) |   14.33657   6.453792      5.932887    34.64373
                 cov
      (visits,_cons) |   1.796512    .661156      .5006704    3.092354
      -----------------------------+------------------------------------------------
      vitamindose_cIdentity       |
                        var(
      _cons) |   45.49714   6.790777      33.95753    60.95819
      -----------------------------+------------------------------------------------
                     var(
      Residual) |    63.3871   2.212747      59.19523    67.87581
      ------------------------------------------------------------------------------
      LR test vslinear modelchi2(4) = 1369.79               Prob chi2 0.0000

      Note
      LR test is conservative and provided only for reference

      Comments and suggestions will be greatly appreciated.

      Sincerely,
      Al Bothwell

      Comment


      • #4
        I don't understand the reasoning behind making vitamin dose a random effect. I don't think I would do that.

        To achieve the goal of modeling whether vitamin dose moderates the effect of treatment on weight change, all you need is the model I suggested in #2, even if vitamin dose is varying in some patients.

        Now, if your question is really whether the moderating effect of vitamin dose differs between those who took a constant dose and those who decreased their dose over time, that is a different matter and would require a more complicated model. But even there, you would not use a random intercept for vitamin dose.

        Comment


        • #5
          Thank you Clyde. I will run the model suggested in #2.


          Comment

          Working...
          X