st: arranging columns in estout

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: arranging columns in estout

Richard Hiscock-2
Hi everyone,

I am trying to automate results from univariable logistic regression  
into table using estout package,
my command lines are:

****Unadjusted
local tablist arm asa antib_proph act_lab antib_24 cs_type
set more off
foreach v of varlist `mylist' {
                        eststo: logistic  infection_any `v'
}
estout * , eform cells("b(fmt(1)) p(fmt(2)) ci(fmt(1)) " se(par fmt
(2))) style(fixed) drop(_cons) modelwidth(10)

this produces output as desired except that variables are stacked/
staggered across table (see below). the staggering is not corrected
by saving as a txt file.
Is it possible to arrange est1-est6 in a vertical stack like:

arm b/se   p   ci95
asa     b/se   p   ci95
antib_proph ...


I have searched the estout help file and can't identify a solution.
thanks Richard Hiscock


. estout * , eform cells("b(fmt(1)) p(fmt(2)) ci(fmt(1)) " se(par fmt
(2))) style(fixed) drop(_cons) modelwidth(10)

                    est1                              
est2                             est3                             e
 > st4                             est5                             est6
                    b/se          p       ci95       b/se          
p       ci95       b/se          p       ci95       b
 > /se          p       ci95       b/se          p       ci95       b/
se          p       ci95
arm                 0.6       0.37    0.2,1.7
 >
                  (0.33)
 >
asa                                                  1.0       0.96    
0.5,1.9
 >
                                                   (0.33)
 >
antib_proph
                                                                            1.3
        0.73    0.3,6.6
 >
                                                                                    (1.09
)
 >
act_lab
 > 1.1       0.89    0.4,2.8
                                                                                                                     (0
.
 > 52)
antib_24
 >                                  3.6       0.37   0.2,59.8

 >                               (5.15)
cs_type
 >                                                                    
1.0       0.94    0.4,2.6

 >                                                                (0.49)

 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: st: arranging columns in estout

Ben Jann
For the result you want the model's have to be stacked, which is not
directly supported by -estout-. However, see:
http://repec.org/bocode/e/estout/advanced.html#advanced901

Example:

capt prog drop appendmodels
*! version 1.0.0  14aug2007  Ben Jann
program appendmodels, eclass
    // using first equation of model
    version 8
    syntax namelist
    tempname b V tmp
    foreach name of local namelist {
        qui est restore `name'
        mat `tmp' = e(b)
        local eq1: coleq `tmp'
        gettoken eq1 : eq1
        mat `tmp' = `tmp'[1,"`eq1':"]
        local cons = colnumb(`tmp',"_cons")
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1,1..`cons'-1]
        }
        mat `b' = nullmat(`b') , `tmp'
        mat `tmp' = e(V)
        mat `tmp' = `tmp'["`eq1':","`eq1':"]
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
        }
        capt confirm matrix `V'
        if _rc {
            mat `V' = `tmp'
        }
        else {
            mat `V' = ///
            ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
            ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
        }
    }
    local names: colfullnames `b'
    mat coln `V' = `names'
    mat rown `V' = `names'
    eret post `b' `V'
    eret local cmd "whatever"
end

eststo clear
sysuse auto
foreach v of varlist price mpg weight {
        eststo `v': logit foreign `v'
}
appendmodels price mpg weight
estout ., eform cells("b(fmt(3)) p ci" se(par)) eqlabels(none)


This result in:

. estout ., eform cells("b(fmt(3)) p ci" se(par)) eqlabels(none)

---------------------------------------------------
                        .
                     b/se            p         ci95
---------------------------------------------------
price               1.000        0.676  1.000,1.000
                  (0.000)
mpg                 1.173        0.002  1.058,1.301
                  (0.062)
weight              0.997        0.000  0.996,0.999
                  (0.001)
---------------------------------------------------


ben

On Tue, Nov 24, 2009 at 12:28 PM, Richard Hiscock
<[hidden email]> wrote:

> Hi everyone,
>
> I am trying to automate results from univariable logistic regression into
> table using estout package,
> my command lines are:
>
> ****Unadjusted
> local tablist arm asa antib_proph act_lab antib_24 cs_type
> set more off
> foreach v of varlist `mylist' {
>                        eststo: logistic  infection_any `v'
> }
> estout * , eform cells("b(fmt(1)) p(fmt(2)) ci(fmt(1)) " se(par fmt(2)))
> style(fixed) drop(_cons) modelwidth(10)
>
> this produces output as desired except that variables are stacked/staggered
> across table (see below). the staggering is not corrected
> by saving as a txt file.
> Is it possible to arrange est1-est6 in a vertical stack like:
>
> arm             b/se   p   ci95
> asa             b/se   p   ci95
> antib_proph     ...
>
>
> I have searched the estout help file and can't identify a solution.
> thanks Richard Hiscock
>
>
> . estout * , eform cells("b(fmt(1)) p(fmt(2)) ci(fmt(1)) " se(par fmt(2)))
> style(fixed) drop(_cons) modelwidth(10)
>
>                   est1                             est2
>         est3                             e
>> st4                             est5                             est6
>                   b/se          p       ci95       b/se          p
> ci95       b/se          p       ci95       b
>> /se          p       ci95       b/se          p       ci95       b/se
>>      p       ci95
> arm                 0.6       0.37    0.2,1.7
>>
>                 (0.33)
>>
> asa                                                  1.0       0.96
>  0.5,1.9
>>
>                                                  (0.33)
>>
> antib_proph
>           1.3       0.73    0.3,6.6
>>
>
>       (1.09)
>>
> act_lab
>> 1.1       0.89    0.4,2.8
>
>                                        (0.
>> 52)
> antib_24
>>                                  3.6       0.37   0.2,59.8
>
>>                               (5.15)
> cs_type
>>                                                                   1.0
>>   0.94    0.4,2.6
>
>>                                                                (0.49)
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: difference between two medians

CarlosAlencar
In reply to this post by Richard Hiscock-2
Hi

i am new in using stata...

how coould i compare two medians? what  command should i use?

best regards

Carlos Alencar

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: st: difference between two medians

Maarten buis
--- On Wed, 25/11/09, CarlosAlencar wrote:
> how coould i compare two medians? what  command should
> i use?

Sounds like -qreg-. In the example below the median price
of domestic cars is  4816 and the price of foreign cars is
983 dollars higher, and this difference is significant.

*----- begin example -----
sysuse auto, clear
qreg price foreign
*------ end example -------
( For more on how to use examples I sent to statalist see:
 http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------




     

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AW: st: difference between two medians

Martin Weiss-5

<>

" In the example below the median price of domestic cars is  4816"



-tabstat- yields a different result for the median price of domestic cars, though...


*************

sysuse auto, clear

qreg price foreign

//-tabstat- yields different result
tabstat price, stat(median)  /*
*/ by(foreign) nototal /*
*/ columns(variables)

*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Maarten buis
Gesendet: Mittwoch, 25. November 2009 11:05
An: [hidden email]
Betreff: Re: st: difference between two medians

--- On Wed, 25/11/09, CarlosAlencar wrote:
> how coould i compare two medians? what  command should
> i use?

Sounds like -qreg-. In the example below the median price
of domestic cars is  4816 and the price of foreign cars is
983 dollars higher, and this difference is significant.

*----- begin example -----
sysuse auto, clear
qreg price foreign
*------ end example -------
( For more on how to use examples I sent to statalist see:
 http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------




     

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: R: difference between two medians

Carlo Lazzaro-2
In reply to this post by CarlosAlencar
Carlos might want to take a look at:

Newson R. 2002. Parameters behind "nonparametric" statistics: Kendall's tau,
Somers' D and median differences. The Stata Journal 2(1): 45-64.
Pre-publication draft downloadable from Roger Newson's web site at
http://phs.kcl.ac.uk/rogernewson.

Kind Regards,
Carlo
-----Messaggio originale-----
Da: [hidden email]
[mailto:[hidden email]] Per conto di CarlosAlencar
Inviato: mercoledì 25 novembre 2009 10.48
A: [hidden email]
Oggetto: st: difference between two medians

Hi

i am new in using stata...

how coould i compare two medians? what  command should i use?

best regards

Carlos Alencar

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: AW: R: difference between two medians

Martin Weiss-5

<>

" Pre-publication draft downloadable from Roger Newson's web site at
http://phs.kcl.ac.uk/rogernewson."

With the moving wall at three years for the SJ, you can also access the
original publication free of charge:
http://www.stata-journal.com/sjpdf.html?articlenum=st0007



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Carlo Lazzaro
Gesendet: Mittwoch, 25. November 2009 11:46
An: [hidden email]
Cc: 'CarlosAlencar'
Betreff: st: R: difference between two medians

Carlos might want to take a look at:

Newson R. 2002. Parameters behind "nonparametric" statistics: Kendall's tau,
Somers' D and median differences. The Stata Journal 2(1): 45-64.
Pre-publication draft downloadable from Roger Newson's web site at
http://phs.kcl.ac.uk/rogernewson.

Kind Regards,
Carlo
-----Messaggio originale-----
Da: [hidden email]
[mailto:[hidden email]] Per conto di CarlosAlencar
Inviato: mercoledì 25 novembre 2009 10.48
A: [hidden email]
Oggetto: st: difference between two medians

Hi

i am new in using stata...

how coould i compare two medians? what  command should i use?

best regards

Carlos Alencar

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: RE: AW: R: difference between two medians

Roger Newson
Alternatively, if you wanted to estimate differences between medians instead of median differences, you might want to use the -bpmedian- package and/or the -invcise- package, both of which can be downloaded from SSC using the -ssc- command. These packages use the method of inverse confidence interval standard errors.

The median difference is not the same thing as a difference between medians. This distinction causes a lot of culture shock to people who are accustomed to working with means and their differences. A few methodology documents on this issue are available from my website at
http://www.imperial.ac.uk/nhli/r.newson/papers.htm#miscellaneous_documents

Note that my website is now at Imperial College (see my signature below), and has not been at its old KCL address since 2006.

I hope this helps.

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [hidden email]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin Weiss
Sent: 25 November 2009 10:46
To: [hidden email]
Subject: st: AW: R: difference between two medians


<>

" Pre-publication draft downloadable from Roger Newson's web site at
http://phs.kcl.ac.uk/rogernewson."

With the moving wall at three years for the SJ, you can also access the
original publication free of charge:
http://www.stata-journal.com/sjpdf.html?articlenum=st0007



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Carlo Lazzaro
Gesendet: Mittwoch, 25. November 2009 11:46
An: [hidden email]
Cc: 'CarlosAlencar'
Betreff: st: R: difference between two medians

Carlos might want to take a look at:

Newson R. 2002. Parameters behind "nonparametric" statistics: Kendall's tau,
Somers' D and median differences. The Stata Journal 2(1): 45-64.
Pre-publication draft downloadable from Roger Newson's web site at
http://phs.kcl.ac.uk/rogernewson.

Kind Regards,
Carlo
-----Messaggio originale-----
Da: [hidden email]
[mailto:[hidden email]] Per conto di CarlosAlencar
Inviato: mercoledì 25 novembre 2009 10.48
A: [hidden email]
Oggetto: st: difference between two medians

Hi

i am new in using stata...

how coould i compare two medians? what  command should i use?

best regards

Carlos Alencar

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

st: RE: RE: AW: R: difference between two medians

Nick Cox
I imagine there is a connection here to Martin's earlier post.

Given

regress <response> <indicator>

you can recover the means for indicator == 0 and indicator == 1. That's
part of the magic of least squares.

But it's not necessarily true that given

qreg <response> <indicator>

you can recover the equivalent medians. Working with a norm based on
absolute differences doesn't have that side effect in general.

Nick
[hidden email]

Newson, Roger B

The median difference is not the same thing as a difference between
medians. This distinction causes a lot of culture shock to people who
are accustomed to working with means and their differences.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: st: arranging columns in estout

Laura Gibson
This post has NOT been accepted by the mailing list yet.
In reply to this post by Ben Jann
I have been using appendmodels in conjunction with the estout package to make the coefficient estimates from a series of univariate logistic regressions with the same dependent variable appear in one stacked column rather than on a diagonal in Excel. We ran into a bit of trouble with it when we needed to use non-standard estimates (e.g., smaller CIs than 95%).

One solution (for working in Excel) does not require appendmodels. It simply changes the delimiter from tab to a character that we do not expect to show up in the results or the variable names (e.g., @).

*For example, for storing the 83.4% confidence intervals:
eststo: logistic dv iv, le(83.4)
estadd r(table)
*For printing those intervals with the @ delimiter
estout using filename.csv, eform cells("b table[5] table[6]") replace delimiter(@)

When we open the results in Excel, we can then change data from text to columns, with the delimiter specified as "@" and checking the box for "consecutive delimiters treated as one".

This seemed like a useful work-around for us, and I thought it might be useful to others as well.

Best,
-Laura Gibson
University of Pennsylvania

Ben Jann wrote
For the result you want the model's have to be stacked, which is not
directly supported by -estout-. However, see:
http://repec.org/bocode/e/estout/advanced.html#advanced901

Example:

capt prog drop appendmodels
*! version 1.0.0  14aug2007  Ben Jann
Loading...