Announcement

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

  • Calculating annual increase or decrease in mortality after multivariate logistic regression model

    Dear Stata user

    Can anyone please help me to figure out how can I calculate and report adjusted changes in mortality after logistic regression. I have a longitudinal data over 30 years where I am calculating mortality changes over time. obviously I am adjusting for all the potential confounders in the model. I have introduced "year" as a continuous variable in the model which gives me adjusted odd ratio for each year. However, I am interested to report these odds ratio as a percentage change per year. I have tried margins, atmeans, but this given my means for all the variables including the means for all years. am I right to think that this is not a percentage increase or decrease in mortality? sorry to be nob I will be extremely grateful for your help in this matter.


  • #2
    Well, you don't show your actual logistic regression command, so I'm not sure what you've done. And I don't know what the range of values for the year variable is. For illustration purposes I'll assume that year ranges from 1 to 30. Modify the code accordingly:

    Code:
    margins, dydx(year) at(year = (1(1)29))
    This will give you the adjusted increments in mortality (assuming mortality was in fact the outcome variable in the logistic model) each year. As written, the command will do the adjustment to the observed distribution of all of the model covariates in your estimation sample. From your original attempt, however, it seems you may prefer rather to adjust all the covariates to their mean values. If so, just add -atmeans- to the end of the command.

    Added: In the future, it is best to show the estimation commands you have actually run when you want help with interpretation of the results or help with post-estimation commands. One or two lines of code is usually much more informative than several paragraphs of narrative. And it usually doesn't hurt to fire up -dataex- and show example data, too.

    Comment


    • #3
      Dear Clyde

      Thank you so much for the help, the data is very big over 30 years, Please see below the short example of the model output I have run over the later years. I obviously get the yearly adjusted odds ratios ( which become significant with narrow point estimates once I adjust for more confounders) I am really sorry for not posting this earlier. I am not familiar with -dataex- and right now looking at a youtube video to see how I can do this as well.



      logistic death i.SHF c.AGE i.YEAR

      Logistic regression Number of obs = 351,144
      LR chi2(13) = 1914.97
      Prob > chi2 = 0.0000
      Log likelihood = -33876.671 Pseudo R2 = 0.0275

      ------------------------------------------------------------------------------
      death | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      1.SHF1 | 1.486133 .0422969 13.92 0.000 1.405502 1.571389
      AGE | 1.038926 .0009917 40.01 0.000 1.036984 1.040871
      |
      YEAR |
      2005 | .9379712 .0779373 -0.77 0.441 .7970068 1.103868
      2006 | .9448996 .0766574 -0.70 0.485 .8059902 1.10775
      2007 | .9423053 .0753371 -0.74 0.457 .8056349 1.102161
      2008 | 1.153527 .0834659 1.97 0.048 1.001007 1.329285
      2009 | 1.199922 .0853529 2.56 0.010 1.043771 1.379433
      2010 | 1.211955 .0857572 2.72 0.007 1.055008 1.392249
      2011 | 1.205718 .0829562 2.72 0.007 1.053613 1.379782
      2012 | 1.252829 .0866294 3.26 0.001 1.094041 1.434663
      2013 | 1.305883 .0888665 3.92 0.000 1.142824 1.492208
      2014 | 1.236164 .0834829 3.14 0.002 1.082907 1.41111
      2015 | 1.210767 .0840903 2.75 0.006 1.056678 1.387325
      |
      _cons | .0009848 .0000916 -74.45 0.000 .0008207 .0011817



      As per my question, instead of reporting an adjusted odds ratio per year, I want to report the annual percentage change in mortality with respective 95%CI and P values. if I got it right then my post estimation command after running the model would something like
      margins, dydx(YEAR) at (YEAR=2004(1)2015))

      Comment


      • #4
        My final results table should look something like this, I am obviously looking to get the adjusted death per year in the third row in the table below.
        Death 2004 2005 2006 2007 2008 2010 2011 2012 2013 2014 2015 Odds ratio per year
        Unadjusted death 3.1% 3.3% 3.9% 4.7% 4.8% 5.1% 5.6% 5.9% 6.6% 6.9% 7.1% OR 0.968 (0.982-0.971)
        Adjusted death
        I have now run your command as below which has produced the following results which I don't understand all now.

        margins, dydx(YEAR) at(YEAR = (2004(1)2015))

        Average marginal effects Number of obs = 351,149
        Model VCE : OIM

        Expression : Pr(DIED), predict()
        dy/dx w.r.t. : 2005.YEAR 2006.YEAR 2007.YEAR 2008.YEAR 2009.YEAR 2010.YEAR 2011.YEAR 2012.YEAR 2013.YEAR 2014.YEAR 2015.YEAR

        1._at : YEAR = 2004

        2._at : YEAR = 2005

        3._at : YEAR = 2006

        4._at : YEAR = 2007

        5._at : YEAR = 2008

        6._at : YEAR = 2009

        7._at : YEAR = 2010

        8._at : YEAR = 2011

        9._at : YEAR = 2012

        10._at : YEAR = 2013

        11._at : YEAR = 2014

        12._at : YEAR = 2015

        ------------------------------------------------------------------------------
        | Delta-method
        | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        2005.YEAR |
        _at |
        1 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        2 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        3 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        4 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        5 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        6 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        7 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        8 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        9 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        10 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        11 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        12 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
        -------------+----------------------------------------------------------------
        2006.YEAR |
        _at |
        1 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        2 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        3 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        4 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        5 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        6 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        7 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        8 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        9 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        10 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        11 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        12 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
        -------------+----------------------------------------------------------------
        2007.YEAR |
        _at |
        1 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        2 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        3 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        4 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        5 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        6 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        7 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        8 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        9 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        10 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        11 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        12 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
        -------------+----------------------------------------------------------------
        2008.YEAR |
        _at |
        1 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        2 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        3 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        4 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        5 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        6 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        7 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        8 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        9 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        10 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        11 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        12 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
        -------------+----------------------------------------------------------------
        2009.YEAR |
        _at |
        1 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        2 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        3 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        4 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        5 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        6 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        7 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        8 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        9 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        10 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        11 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        12 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
        -------------+----------------------------------------------------------------
        2010.YEAR |
        _at |
        1 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        2 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        3 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        4 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        5 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        6 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        7 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        8 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        9 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        10 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        11 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        12 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
        -------------+----------------------------------------------------------------
        2011.YEAR |
        _at |
        1 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        2 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        3 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        4 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        5 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        6 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        7 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        8 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        9 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        10 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        11 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        12 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
        -------------+----------------------------------------------------------------
        2012.YEAR |
        _at |
        1 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        2 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        3 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        4 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        5 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        6 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        7 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        8 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        9 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        10 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        11 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        12 | .0031294 .0013115 2.39 0.017 .000559 .0056998
        -------------+----------------------------------------------------------------
        2013.YEAR |
        _at |
        1 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        2 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        3 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        4 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        5 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        6 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        7 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        8 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        9 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        10 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        11 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        12 | .0037156 .0013007 2.86 0.004 .0011663 .006265
        -------------+----------------------------------------------------------------
        2014.YEAR |
        _at |
        1 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        2 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        3 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        4 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        5 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        6 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        7 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        8 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        9 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        10 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        11 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        12 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
        -------------+----------------------------------------------------------------
        2015.YEAR |
        _at |
        1 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        2 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        3 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        4 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        5 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        6 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        7 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        8 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        9 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        10 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        11 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        12 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
        ------------------------------------------------------------------------------
        Note: dy/dx for factor levels is the discrete change from the base level.

        Comment


        • #5
          OK, sorry, I forgot that when you do -dydx()- with a discrete variable you get all of its levels reported. So you can simplify the margins command to just -margins, dydx(YEAR)- without the -at()- option. That way you won't get 12 repetitions of every result.

          Comment


          • #6
            Dear Clyde

            I am really sorry to be a dumb here, I have following table after using the command
            margins, dydx (YEAR)

            . margins, dydx(YEAR)

            Average marginal effects Number of obs = 351,149
            Model VCE : OIM

            Expression : Pr(DIED), predict()
            dy/dx w.r.t. : 2005.YEAR 2006.YEAR 2007.YEAR 2008.YEAR 2009.YEAR 2010.YEAR 2011.YEAR 2012.YEAR 2013.YEAR 2014.YEAR 2015.YEAR

            ------------------------------------------------------------------------------
            | Delta-method
            | dy/dx Std. Err. z P>|z| [95% Conf. Interval]
            -------------+----------------------------------------------------------------
            YEAR |
            2005 | -.0009253 .0014474 -0.64 0.523 -.0037622 .0019116
            2006 | -.000664 .0014246 -0.47 0.641 -.0034562 .0021282
            2007 | -.0007212 .0014028 -0.51 0.607 -.0034708 .0020283
            2008 | .0019428 .001348 1.44 0.150 -.0006993 .0045849
            2009 | .0026055 .0013405 1.94 0.052 -.0000218 .0052328
            2010 | .0027016 .0013342 2.02 0.043 .0000867 .0053166
            2011 | .0025827 .0012907 2.00 0.045 .0000529 .0051124
            2012 | .0031294 .0013115 2.39 0.017 .000559 .0056998
            2013 | .0037156 .0013007 2.86 0.004 .0011663 .006265
            2014 | .0024123 .0012691 1.90 0.057 -.000075 .0048997
            2015 | .0019275 .0013014 1.48 0.139 -.0006232 .0044781
            ------------------------------------------------------------------------------

            I still don't get it whether these are percentage changes per year, for instance, -0.0009 in 2005 is equivalent to what?

            Comment


            • #7
              It means that compared to 2004, mortality probability declined by 0.0009, or, equivalently, by 0.09 percentage point. And in, say, 2007 compared to 2004, it declined by 0.07 percentage point.

              If you want to compare each year to the preceding year, you can do that with
              Code:
              contrast ar.year

              Comment


              • #8
                Thank you Clyde, This is perfect. very very helpful indeed.

                Comment

                Working...
                X