Announcement

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

  • ereturn repost and updating statistic and p-value

    Hi everyone,

    I'm working on code to apply certain types of standard error corrections to GEE analyses. I want to be able to output a regression table to the Stata output window that looks like the standard Stata regression output table.

    So, first, see below for the code running the standard xtgee command to run a GEE model.

    Code:
    xtgee know arm stratum_2 stratum_3 ethnicgp_2, family(binomial) link(logit) scale(phi) nmp eform
    
    
    GEE population-averaged model                   Number of obs     =      4,100
    Group variable:                  community      Number of groups  =         20
    Link:                                logit      Obs per group:
    Family:                           binomial                    min =        169
    Correlation:                  exchangeable                    avg =      205.0
                                                                  max =        257
                                                    Wald chi2(4)      =      43.94
    Scale parameter:                  .9957369      Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
            know | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   2.286608   .3382258     5.59   0.000      1.71114    3.055611
       stratum_2 |   1.051687   .1881703     0.28   0.778     .7406063    1.493432
       stratum_3 |   1.133454   .2176577     0.65   0.514     .7779419    1.651431
      ethnicgp_2 |    .737854   .0647369    -3.47   0.001      .621282    .8762986
           _cons |   .9892138   .1621198    -0.07   0.947     .7174454    1.363928
    ------------------------------------------------------------------------------
    Note: _cons estimates baseline odds (conditional on zero random effects).
    I then apply a certain correction to the standard errors. If I keep the same z-statistic, it is easy enough to get an updated regression output table after using ereturn repost followed by _coef_table, as follows:

    Code:
    _coef_table, eform
    
    ------------------------------------------------------------------------------
            know |     exp(b)   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   2.286608   .4261085     4.44   0.000     1.586977    3.294677
       stratum_2 |   1.051687   .2531373     0.21   0.834      .656153    1.685651
       stratum_3 |   1.133454    .269032     0.53   0.598     .7118133    1.804852
      ethnicgp_2 |    .737854   .0793335    -2.83   0.005     .5976541    .9109426
           _cons |   .9892138   .2181314    -0.05   0.961      .642084    1.524013
    ------------------------------------------------------------------------------
    However, I also want to be able to use a t-statistic, which according to simulations under certain types of corrections is a better option, but which xtgee does not provide an option for. (Note that in this case there is no difference between the t-statistic and z-statistic, but ignore that for now.) Thus, I compute the t-statistic and updated p-value separately, but I don't think there's a way to update these using ereturn repost. So, the closest I've been able to come to recreating the format of the regression output is using tabdisp, but there are a couple issues. (I've used the list command, but the output doesn't look as nice.) One is that tabdisp sorts the data by the first column automatically, and I'm not sure how to override this. The other is that I can't figure out how to get the columns to be the width I want them to be. I've tried reformatting the numbers and also formatting them as strings and then trimming leading blanks, but this doesn't seem to have any effect. Also, tabdisp does provide a column width changer, but it changes all columns at once, which I don't want. I would want each column to be a different width. See below:

    Code:
    tabdisp know, cell(exp_Coef StdErr t pval CI)
    
    
    -------------------------------------------------------------------------------------------------------------------------
          know |           Odds Ratio             Std. Err.                     t                 P>|t|  [95% Conf. Interval]
    -----------+-------------------------------------------------------------------------------------------------------------
         _cons |             .9892138              .2181314                  -.05                  .961     .61826     1.5827
           arm |             2.286608              .4261086                  4.44                     0     1.5371     3.4017
    ethnicgp_2 |              .737854              .0793335                 -2.83                  .013     .58674     .92789
     stratum_2 |             1.051687              .2531373                   .21                  .837     .62962     1.7567
     stratum_3 |             1.133454               .269032                   .53                  .605     .68342     1.8798
    -------------------------------------------------------------------------------------------------------------------------
    Any ideas for how to solve this issue, potentially of alternative commands I could use, or a way to get ereturn repost to update the statistic and p-value?

    Thank you,
    John

  • #2
    Hi everyone,

    I just wanted to follow up for future reference that I ended up figuring out what to do here. Basically, I use

    Code:
    matrix b=e(b)
    ereturn repost V = var`bcv'
    matrix V=e(V)
    where repost is used because I edited the V (covariance) matrix within Mata to apply a small-sample bias correction.

    Then, I use the following code:

    Code:
    ereturn post b V, dof(`dof')
    ereturn matrix var`bcv' = var`bcv'
    _coef_table, eform
    where dof specifies the degrees of freedom for the t-statistic test. Specifying this automatically tells Stata that we're using a t-statistic, and voila, we have a GEE analysis with t-statistics rather than z-statistics. You can see it in action using code from our newly-created Stata program xtgeebcv for small-sample bias-corrected variance estimation for GEE analyses of cluster randomized trials:

    Code:
    . ssc describe xtgeebcv
    . net install xtgeebcv
    . net get xtgeebcv
    . use mkvtrial.dta
    
    . xtgeebcv know arm stratum ethnicgp, family(binomial) link(log) categorical(stratum ethnicgp) outcome(know) ///
                cluster(community) std_err(KC) eform nolog statistic(t)
    Code:
    
    Note: Family is binomial and link is log
    Using exchangeable working correlation
    with scale parameter divided by K - p
    
    GEE population-averaged model                   Number of obs     =      4,100
    Group variable:                  community      Number of groups  =         20
    Link:                                  log      Obs per group:
    Family:                           binomial                    min =        169
    Correlation:                  exchangeable                    avg =      205.0
                                                                  max =        257
                                                    Wald chi2(4)      =      50.34
    Scale parameter:                         1      Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
            know |     exp(b)   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   1.447557   .0944484     5.67   0.000     1.273789     1.64503
       stratum_2 |    1.01559   .0740027     0.21   0.832     .8804285    1.171501
       stratum_3 |   1.063554   .0803272     0.82   0.415     .9172136    1.233242
      ethnicgp_2 |   .8867641   .0290624    -3.67   0.000     .8315937    .9455946
           _cons |   .4833505   .0356744    -9.85   0.000     .4182519    .5585812
    ------------------------------------------------------------------------------
     
    Kauermann-Carroll bias-corrected standard errors
    t-statistic with K - p degrees of freedom
    ------------------------------------------------------------------------------
                 |     exp(b)   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             arm |   1.447557   .1072803     4.99   0.000      1.23604     1.69527
       stratum_2 |    1.01559   .0845628     0.19   0.855      .850437    1.212815
       stratum_3 |   1.063554   .0830441     0.79   0.442     .9004942    1.256139
      ethnicgp_2 |   .8867641   .0378899    -2.81   0.013     .8095721    .9713163
           _cons |   .4833505   .0432934    -8.12   0.000     .3993464    .5850251
    ------------------------------------------------------------------------------

    Comment

    Working...
    X