Announcement

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

  • Formatting output with outreg

    I’m using the excellent outreg package to merge results from multiple xtmelogit models (2-level, random intercept models) into a nicely formatted Word table.

    Below is a typical command I run after running an xtmelogit:

    outreg using ModelResults, nosubstat stats(b se) varlabels merge ///
    ctitles("","","Coef.","Std. Err.") ///
    title("Results of models 1 - 4")

    The documentation in the help file and at https://www.pdx.edu/sites/www.pdx.ed.../outreg_sj.pdf indicates I should be able to includes odds ratios and 95% CIs, but I can't figure out where those commands go (they don't work if put them inside the stats( ) argument.

    Also, with outreg is that any way to get some of the multilevel stats into the table? For example, the variance of the intercept (var(_cons), the LR test results (e.g., chibar2 = 6200, p < .001), Wald chi2, etc.?

    Thank you!

  • #2
    This post asks several questions about using outreg after the xtmelogit command. (Apparently the xtmelogit command has been superseded by the meqrlogit command.)
    1) How do I display odds ratios?
    2) How do I display 95% confidence intervals?
    3) How do I display 95% odds ratio confidence intervals?
    4) How do I display saved e() values like the LR chi-squared test statistic?
    5) How do I display a statistic that is not one of the e() values, like the variance of the constant term?

    This post will use data from the first help example for xtmelogit:
    . webuse towerlondon, clear
    (Tower of London data)

    . xtmelogit dtlm difficulty i.group || family: || subject:, or

    ...
    Wald chi2(3) = 74.89
    Log likelihood = -305.12043 Prob > chi2 = 0.0000

    ------------------------------------------------------------------------------
    dtlm | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    difficulty | .192337 .0371622 -8.53 0.000 .131704 .2808839
    |
    group |
    2 | .7798296 .2763767 -0.70 0.483 .3893393 1.561964
    3 | .3491339 .1396499 -2.63 0.009 .1594117 .7646519
    |
    _cons | .2263075 .064463 -5.22 0.000 .1294901 .3955133
    ------------------------------------------------------------------------------
    ...

    1) How do I display odds ratios?

    You can display the coefficients in terms of odds ratios with the or option:

    . outreg, or
    dtlm
    difficulty 0.192
    (8.53)**
    2bn.group 0.780
    (0.70)
    3.group 0.349
    (2.63)**
    N 677
    * p<0.05; ** p<0.01

    [Note that the outreg tables look different both in the Stata Results Window and in a Word or TeX file than they do in this post. It does not seem to be possible to reproduce their actual appearance on this forum. See the attached .pdf file to see what the tables look like in Word.]

    This displays the odds ratio of the coefficients plus the t-statistics (which are the same whether you are reporting regular coefficients or odds ratios). outreg drops the constant term when reporting odd ratios.

    The odds ratios are the exponentiated form of the coefficients, i.e. exp(b), which can be specified in the stats option as e_b. An equivalent way to show odds ratios instead of the or option is this stats option:

    . outreg, stats(e_b t)

    Standard errors of odds ratios can be substituted for the t-statistics either with a combination of the or and se options, or with the stats option:

    . outreg, se or
    or
    . outreg, stats(e_b e_se)

    Note that you cannot combine the or or se options with the stats option.

    2) How do I display the 95% confidence intervals?

    The display of confidence intervals can only be specified with the stats option as the statistic ci. The significance level is specified by the level command or the level option of outreg:

    . outreg, stats(b ci) level(99)

    The default significance level is 95%, so the level option is not needed for a 95% significance level.

    The following command displays confidence intervals below the coefficient estimates and t-statistics:

    . outreg, stats(b t ci)

    eq1 difficulty -1.649
    (-8.53)**
    [-2.027 - -1.270]
    2bn.group -0.249
    (-0.70)
    [-0.943 - 0.446]
    3.group -1.052
    (-2.63)**
    [-1.836 - -0.268]
    _cons -1.486
    (-5.22)**
    [-2.044 - -0.928]
    lns1_1_1 _cons -0.282
    (-0.61)
    [-1.180 - 0.616]
    lns2_1_1 _cons 0.065
    (0.21)
    [-0.526 - 0.655]
    N 677
    * p<0.05; ** p<0.01


    The same statistics can be displayed side-by-side with the nosubstat option:

    . outreg, stats(b t ci) nosubstat ctitles("","","Coeff","t stat","Conf. Int.")
    Coeff t stat Conf. Int.
    eq1 difficulty -1.649 -8.53** -2.027 - -1.270
    2bn.group -0.249 -0.70 -0.943 - 0.446
    3.group -1.052 -2.63** -1.836 - -0.268
    _cons -1.486 -5.22** -2.044 - -0.928
    lns1_1_1 _cons -0.282 -0.61 -1.180 - 0.616
    lns2_1_1 _cons 0.065 0.21 -0.526 - 0.655
    * p<0.05; ** p<0.01

    3) How do I display 95% odds ratio confidence intervals?

    Use the stats(e_ci) option (e_ci specify the odds ratio or exponentiated confidence intervals). The following command displays the odds ratios, their t-statistics, and their 95% confidence intervals.

    . outreg, stats(e_b t e_ci)

    4) How do I display one of the saved e() values like the likelihood ratio test chi-squared statistic?

    You can display any of the e() values with the summstat option. You can see all the saved e() values after any estimation command with the ereturn list command. To display both the Wald chi-squared test and the LR chi-squared test with the p values:

    . outreg, nosubstat or summstat(chi2, p \ chi2_c, p_c) ///
    > summtitle("Wald test statistic & p value" \ "LR test statistic & p value")
    difficulty 0.192 8.53**
    2bn.group 0.780 0.70
    3.group 0.349 2.63**
    Wald test statistic & p value 74.89 0.00
    LR test statistic & p value 17.54 0.00
    * p<0.05; ** p<0.01

    5) How do I display a statistic that is not one of the e() values, like the variance of the constant term?

    The variance of the constant term is saved in the coefficient variance-covariance matrix e(V). After extracting the variance of the constant term and numerically formatting the result, you can include the statistic in an outreg table with the addrows option:

    . matrix V = e(V) // use variance-covariance matrix e(V)

    . matrix V_cons = V["eq1:_cons","eq1:_cons"] // select constant term from V

    . local V_cons_str = el(V_cons,1,1) // need el() function to convert 1x1 matrix to local

    . local V_cons_str : display %5.4f `V_cons_str' // format number in V_cons_str

    . outreg, addrows("Variance of constant", "`V_cons_str'")
    eq1 difficulty -1.649
    (8.53)**
    2bn.group -0.249
    (0.70)
    3.group -1.052
    (2.63)**
    _cons -1.486
    (5.22)**
    lns1_1_1 _cons -0.282
    (0.61)
    lns2_1_1 _cons 0.065
    (0.21)
    N 677
    Variance of constant 0.0811
    * p<0.05; ** p<0.01

    I hope that helps.
    Attached Files
    Last edited by John Gallup; 30 Jul 2014, 20:08.

    Comment


    • #3
      quick question: do I need to create a new file in word named something like ModelResults first? the help guide says it 'creates a Word file' but i'm not seeing where that Word file is actually created.

      Comment


      • #4
        sorry about my previous stupid question :/ sorted!

        Comment

        Working...
        X