Hi
I was wondering how to obtain appropriate lincom results after using transform_margins.

I am using svy:logistic to analyze a survey database. Margins after the svy:logistic model gave confidence intervals with negative values, so I used margins with the linear predictor, and then used transform_margins discussed by Jeff Pitblado here :
https://stats.stackexchange.com/ques...rgins-in-stata

This provided estimates with confidence intervals that were not negative.

I would like to assess the difference between two levels of a variable for the linear predictor margins, and ensure that the confidence intervals are appropriate. lincom does not seem to be appropriate for the linear predictor margins. I have tried nlcom with the invlogit of each of the estimates, and this seems to provide a reasonable estimate. However, does anyone know if this provides the appropriate estimate and confidence interval for the difference?

an example is below:
Code:
. webuse nhanes2
. quietly svy, subpop(if agegrp>3):logit diabetes bmi black##female

*using the probabilities
**********************************************************************
. margins female, at(black=(0 1)) subpop(if agegrp>3) vce(unconditional) post
------------------------------------------------------------------------------
             |             Linearized
             |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
  _at#female |
        1 0  |   .0672466   .0073744     9.12   0.000     .0522064    .0822868
        1 1  |    .066051    .004407    14.99   0.000     .0570628    .0750391
        2 0  |   .1287978   .0245295     5.25   0.000     .0787696    .1788259
        2 1  |   .0915743   .0170822     5.36   0.000     .0567349    .1264138
------------------------------------------------------------------------------


. lincom _b[2._at#1.female]-_b[1bn._at#1.female]
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0255234   .0176777     1.44   0.159    -.0105305    .0615773
------------------------------------------------------------------------------

. 


*using the linear predictor
**********************************************************************
. margins female, at(black=(0 1)) subpop(if agegrp>3) vce(unconditional) exp(predict(xb)) post
------------------------------------------------------------------------------
             |             Linearized
             |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
  _at#female |
        1 0  |  -2.676449   .1199975   -22.30   0.000    -2.921185   -2.431712
        1 1  |  -2.695843   .0717618   -37.57   0.000    -2.842202   -2.549484
        2 0  |  -1.949814   .2179706    -8.95   0.000    -2.394368    -1.50526
        2 1  |  -2.337782    .211021   -11.08   0.000    -2.768162   -1.907402
------------------------------------------------------------------------------

. transform_margins invlogit(@)
----------------------------------------------
             |         b         ll         ul
-------------+--------------------------------
  _at#female |
        1 0  |  .0643774   .0511162   .0807862
        1 1  |  .0632191   .0550858   .0724611
        2 0  |  .1245737   .0836032   .1816423
        2 1  |  .0880418   .0590691    .129273
----------------------------------------------


. lincom _b[2._at#1.female]-_b[1bn._at#1.female]
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |    .358061   .2201364     1.63   0.114    -.0909101    .8070322
------------------------------------------------------------------------------


. nlcom invlogit(_b[2._at#1.female])-invlogit(_b[1bn._at#1.female])
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _nl_1 |   .0248227   .0173011     1.43   0.151    -.0090867    .0587322
------------------------------------------------------------------------------