Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: RE: Create a table of estimation results from several simple regressions


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: RE: RE: Create a table of estimation results from several simple regressions
Date   Wed, 30 May 2012 12:57:26 +0100

"conformability error" is reported in 11.2 but not 12.1. I surmise that you need 12 up for this to work. 

The reason is that r(table) is not produced in Stata < 12. Thus -matrix turn- is born a scalar matrix with missing values, at least in versions of Stata that allow matrices to hold missing values. 

Ángel will need another way to do this. -eret li- shows what is available as raw material after -regress-. 

Nick 
[email protected] 

Ángel Rodríguez Laso

I'm also interested in Hasan's question and I've tried your promising
code with the following result (working with Stata 9.2 for Windows):

. reg price mpg

      Source |       SS       df       MS              Number of obs =      74
-------------+------------------------------           F(  1,    72) =   20,26
       Model |   139449474     1   139449474           Prob > F      =  0,0000
    Residual |   495615923    72  6883554,48           R-squared     =  0,2196
-------------+------------------------------           Adj R-squared =  0,2087
       Total |   635065396    73  8699525,97           Root MSE      =  2623,7

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         mpg |  -238,8943   53,07669    -4,50   0,000    -344,7008   -133,0879
       _cons |   11253,06   1170,813     9,61   0,000     8919,088    13587,03
------------------------------------------------------------------------------

. matrix mpg = r(table)'

. matrix mpg = mpg[1,1..2],e(N)
conformability error
r(503);

2012/5/30 Lance Erickson <[email protected]>:

> When I have problems like this I take advantage of the results Stata saves
> after a model and put the information I need into a matrix. The help file
> for -esttab- suggests it can tabulate matrices. So you might do something
> like this...
>
>
> sysuse auto, clear
>
> reg price mpg
> matrix mpg = r(table)'
> matrix mpg = mpg[1,1..2],e(N)
>
> reg price rep78
> matrix rep78 = r(table)'
> matrix rep78 = rep78[1,1..2],e(N)
>
> reg price turn
> matrix turn = r(table)'
> matrix turn = turn[1,1..2],e(N)
>
> matrix table = mpg\rep78\turn
>
> matrix colnames table = b se N
>
> esttab matrix(table)
>
>
> Of course, you can modify the output table as described in the -esttab-
> help file (Ben Jann from SSC) but this should give you the basic structure
> you're looking for. (Although not necessary, looping through the independent
> variables would be more efficient and wouldn't be too difficult if you're
> familiar with using -foreach-.)

David Radwin

> You might find it easiest to create your own (pipe- or comma- or
> tab-delimited) text file using the -file- command. This will require a
> little programming but will give you much more flexibility. See, for
> example:
>
> http://www.stata.com/statalist/archive/2008-02/msg00362.html

Hassan Enayati

>> I need to create a table of estimation results, including estimates,
>> standard errors, and number of observations, from several simple
>> regressions. The finished table should have the following structure:
>>
>> Model 1 | Estimate | Std. Error | Num. Obs.
>> Model 2 | Estimate | Std. Error | Num. Obs.
>> Model 3 | Estimate | Std. Error | Num. Obs.
>>
>> At first, I used eststo and then esttab. Unfortunately, I can not get
>> the esttab output to take the above specified form. The problem with
>> esttab is that even under the wide option, it tabs over for each
>> model. Additionally, esttab won't place the number of observations as
>> the last entry on a given row. The result looks like the following:
>>
>> M1 | Est | SE |
>>  Number of Obs
>>                   M2 | Est | SE | #
>>                    Number of Obs
>>                                     M3 | Est | SE | #
>>                                      Number of Obs
>>
>> How can I produce a table that looks like the first structure I showed
>> above? Thanks in advance for the help.

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index