Announcement

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

  • Adjusted geometric least square means (adjusted geometric means) with svy prefix and log-transformed outcomes in Stata 14

    Hello,

    I am working with nationally representative biomarker data and thus am working through a number of syntax issues in trying to obtain adjusted geometric mean estimates for biomarkers at each level of a grouping variable. I am using Stata 14 regress commands (log-transformed biomarker data serve as the outcome variables). I would like to adjust for age (continuous), sex (binary), race/ethnicity (4 categories), creatinine (continuous), and then get the geometric means adjusted for these variables by the grouping variable following execution of the regression command. My syntax looks something like this:

    svy, subpop(if eligible==1): regress biomarker_ln c.age i.sex i.Race c.Creat i.Group, eform(exp(Coef.))

    This is giving me exponentiated regression coefficients, which I believe are the geometric mean differences for a given covariate in the model.

    Example:

    biomarker_ln | exp(Coef.) Std. Err. t P>|t| [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    age | 1.017817 .0046482 3.87 0.000 1.008723 1.026993

    sex
    female | 1.281597 .157293 2.02 0.044 1.006924 1.631196

    Race2|
    Non-white | .6388515 .1125512 -2.54 0.011 .4518855 .903174
    Creat | .8179233 .0441127 -3.73 0.000 .7356647 .9093796
    |
    Group |
    1 | .0006994 .0001183 -42.95 0.000 .0005015 .0009752
    2 | 1.400022 .229586 2.05 0.041 1.014303 1.932421
    3 | 1.159951 .2028994 0.85 0.397 .8225093 1.635831

    _cons | 920.7408 246.3742 25.51 0.000 544.1887 1557.848

    After reading through many tutorials (including this helpful summary: https://www3.nd.edu/~rwilliam/stats/Margins01.pdf) and through the very long and daunting manual for the margins command, I think, to get the adjusted means for the ln values, I would run: margins Group - which gives this:

    ------------------------------------------------------------------------------
    | Delta-method
    | Margin Std. Err. t P>|t| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    Group |
    1 | 7.292628 .1147933 63.53 0.000 7.067023 7.518232
    2 | .0272855 .1228874 0.22 0.824 -.2142263 .2687973
    3 | 7.629115 .1155252 66.04 0.000 7.402073 7.856158
    4 | 7.441005 .1305297 57.01 0.000 7.184474 7.697536

    Now, assuming I am correctly interpreting that this would result in the ln means of "biomarker" adjusted for the covariates in the model I had specified (age, sex, race, creat) - I would need to exponentiate each of the four group values in order to obtain the resulting geometric mean. I cannot find a way to do this in a code-based, straightforward manner in Stata 14. (i.e., eform won't work).

    I am wondering if anyone on the forum may be able to confirm that my interpretation of this issue is correct, and if so, if they are aware of a reasonably straightforward, code-based way in which to get the exponentiated values for the margins obtained in this postestimation command? Other alternative code suggestions are options, too.

    Thanks in advance,
    Danielle Smith


  • #2
    The output from the -margins- command you show is not the logarithms of the means. It is the mean of the logarithms of the biomarkers, which is precisely what you want. Exponentiating these will give you the adjusted geometric means.

    Try this to automate the exponentiation:

    Code:
    margins Group, post
    matrix T = r(table)
    matrix M = T[1, 1..4] \ T[5..6, 1..4]
    forvalues i = 1/3 {
        forvalues j = 1/4 {
            matrix M[`i', `j'] = exp(M[`i', `j'])
        }
    }
    matrix list M
    The resulting matrix will have a column for each group. The first row will be the geometric mean in each group, and the second and third rows give lower and upper 95% confidence limits, respectively.

    Comment


    • #3
      This script is doing the trick. Thanks so much for your help!

      Comment


      • #4
        Dear all,

        I have the same problem as Danielle and when I used Clyde's code, it showed errors:
        matrix M = T[1, 1..4] \ T[5..6, 1..4]
        conformability error
        r(503);

        I want to test the difference of biomarker level among 2 groups, adjusted for age, gender, and education. My code is :
        svy:regress ln_biomarker i.group cohort gender i.age i.edu, eform (GM)
        margins group, post
        matrix T = r(table)
        matrix M = T[1, 1..4] \ T[5..6, 1..4]
        forvalues i = 1/3 {
        forvalues j = 1/4 {
        matrix M[`i', `j'] = exp(M[`i', `j'])
        }
        }
        matrix list M

        Could you please help me?
        Thanks so much for your help.
        Best,
        Ly.

        Comment


        • #5
          The reason you are getting that is that in #2 was written in response to an output in #1 that should the variable group as having 4 levels.

          But you have only two groups. So there will not exist 4 different columns in r(table), only 2. So if you replace 1..4 by 1..2 in that -matrix M = …- command, it will work just fine.

          Comment


          • #6
            Thanks so much. It works really well.

            Comment

            Working...
            X