Announcement

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

  • Post-estimation comparison of gradients

    Dear Statalisters,

    I am afraid that my question comes from a lack of statistical knowledge as well as inexperience with stata post-estimation. I have reviewed the following thread as I think this might be close to that which I need:
    https://www.statalist.org/forums/for...-mixed-command

    I have performed a multi-level hierarchical mixed effects model to analyse the rate of decay of a certain lab analyte per participant over time. The dependent variable has been log transformed as the decay appears to be more or less logarithmic.
    The key (fixed) independent variable is what treatment was received (Armcode). There are other fixed independent variables encompassing typical epidemiology. The random variables are the participant site and nested within it participant.

    There are 8 treatment arms. Using the margins and margins plot command, I can pull a graph that (I believe) has these 8 different modelled rates of decay - one for each treatment arm.

    What I would ultimately like to demonstrate is the gradient for each of these lines with 95% confidence intervals (and hence work out the half life of decay for each of these arms) as well as perform an appropriate test to demonstrate the presence of significant differences between these arms in terms of rate of decay.

    Code:
    meglm lnResult i.Armcode##c.Days c.Days i.Armcode c.BMI i.Cardiovascular i.Respiratory i.Diabetes i.Sex c.Age i.Ethnicity || Sitecode: || PID: , vce(robust) level(95)
    
    margins, at(Days=(28 280)) over(Armcode)
    
    marginsplot
    
    contrast rb1.Armcode, effects post
    This gives:
    Code:
    -------------------------------------------------------------------
                                    |         df        chi2     P>chi2
    --------------------------------+----------------------------------
    lnAntiS                         |
                            Armcode |
     (B vs A)  |          1      122.45     0.0000
      (Cvs A)  |          1      237.82     0.0000
     (D vs A)  |          1      186.59     0.0000
    (E vs A)  |          1        5.09     0.0241
     (F vs A)  |          1      224.91     0.0000
      (G vs A)  |          1      175.27     0.0000
     (H vs A)  |          1      248.47     0.0000
                             Joint  |          7    40105.41     0.0000
    -------------------------------------------------------------------
    
    -------------------------------------------------------------------------------------------------
                                    |   Contrast   Std. err.      z    P>|z|     [95% conf. interval]
    --------------------------------+----------------------------------------------------------------
    lnAntiS                         |
                            Armcode |
     (B vs A)  |   2.289706   .2069172    11.07   0.000     1.884156    2.695256
      (C vs A)  |   2.424016    .157185    15.42   0.000     2.115939    2.732093
     (D vs A)  |   1.695048   .1240917    13.66   0.000     1.451833    1.938263
    (E vs A)  |   .3872273   .1717081     2.26   0.024     .0506857    .7237689
     (F vs A)  |   2.328036    .155235    15.00   0.000     2.023781    2.632291
      (G vs A)  |   2.529099    .191032    13.24   0.000     2.154683    2.903514
     (H vs A)  |   2.091184   .1326646    15.76   0.000     1.831166    2.351202
    -------------------------------------------------------------------------------------------------
    However, this clearly does not get me to gradients of lines over time. Time being continuous cannot seem to be included in this contrast command. I feel that I might be close to getting what I need, but any help would be hugely appreciated.
    Best wishes
    Rob

  • #2
    First in your code you have 'c.Days i.Armcode' more times than you should. Stata will drop them anyway. When you have i.Armcode##c.Days the '##' ensures you have both the main and interaction effect in the model and there is no need of separate terms for c.Days i.Armcode.

    Code:
    meglm lnResult i.Armcode##c.Days c.Days i.Armcode c.BMI i.Cardiovascular i.Respiratory i.Diabetes i.Sex c.Age i.Ethnicity || Sitecode: || PID: , vce(robust) level(95)
    If I understand you correctly you want the slopes to be tested w.r.t. each arm at each time (day).

    Code:
    meglm lnResult i.Armcode##c.Days c.BMI i.Cardiovascular i.Respiratory i.Diabetes i.Sex c.Age i.Ethnicity || Sitecode: || PID: , vce(robust) level(95)
    
    margins Armcode , at(Days=(28 (10) 280)
    marginsplot, //graph the means of Armcode for each time
    
    margins , dydx(Armcode) at(Days=(28 (10) 280) //Test at each time
    Last edited by Roman Mostazir; 28 Jan 2022, 09:16.
    Roman

    Comment


    • #3
      Dear Roman,
      Thank you very much for this and apologies for not acknowledging your help sooner. It is taking me a while to work through what I have with your advice, but I will come back to you with an outcome.

      Comment

      Working...
      X