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: rename estimate coefficients: ereturn repost


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: rename estimate coefficients: ereturn repost
Date   Wed, 23 Jan 2013 18:56:31 +0000

If I understand what you are trying, it works for me. Here is a program

program mydisp, eclass
         matrix betass=e(b)
         matrix colnames betass = "aa" "bb" "cc" "DD" "ee" "ff"
         mat list betass
         ereturn repost b = betass, rename
 end

and this uses it

sysuse auto, clear
gen gpm = 1/mpg
reg gpm displacement headroom weight turn trunk
mydisp
mat b = e(b)
mat li b

and this is what I get

. mat li b

b[1,6]
            aa          bb          cc          DD          ee          ff
y1   4.806e-06  -.00065331   .00001154   .00019261   .00038585   .00339977

Seems simpler just to use the names you want as variable names,
although the constant will still be called _cons.

That said, I can't advise on -outreg2- (SSC), -outreg- (SJ, SSC) and
-estout- (SJ, SSC) except to make a factual comment that the comments
in the -outreg2- documentation on -outreg- don't make sense except in
reference to a now superseded version of -outreg-.

Nick

P.S. On pleas for urgency, see
http://www.stata.com/support/faqs/resources/statalist-faq/#others


On Wed, Jan 23, 2013 at 6:04 PM, Johannes Breckenfelder
<Johannes.Breckenfelder@hhs.se> wrote:
> Thank you very much, Aljar, for the comments below. Unfortunately it doesn't solve my problem, it would be awesome if you could have another look:
>
> I'm starting off with these stored estimates:
> ****************************************************************************
> .         eret list
>
> scalars:
>                   e(N) =  534
>
> macros:
>                 e(cmd) : "regress"
>              e(depvar) : "Excess Return"
>          e(properties) : "b V"
>
> matrices:
>                   e(b) :  1 x 5
>                   e(V) :  5 x 5
>
> functions:
>              e(sample)
> ***************************************************************************
>
> Next, I'm running this procedure to change column names:
> ****************************************************************************
> program drop disp2
> program disp2, eclass
>         matrix betass=e(b)
>         matrix colnames betass = "aa" "bb" "cc" "DD" "ee" "ff"
>         mat list betass
>         ereturn repost b = betass, rename
> end
> ****************************************************************************
>
> Then, I check whether it actually did change -and it didn't....
> ****************************************************************************
>
>         matrix betass=e(b)
>         mat list betass
>
> betass[1,6]
>            r1         r2         r3         r4         r5         r6
> y1  1.0086253  .76111561  .00520306  .26619872  .02242498          0
> ****************************************************************************
>
> ... even though the individual step does work:
> ****************************************************************************
>
>           matrix colnames betass = "aa" "bb" "cc" "DD" "ee" "ff"
>           mat list betass
>
> betass[1,6]
>            aa         bb         cc         DD         ee         ff
> y1  1.0086253  .76111561  .00520306  .26619872  .02242498          0
> ****************************************************************************
>
> Somehow it doesn't go through... Any ideas?

Aljar Meesters

> I do not know what you exactly want to do, but in order to get your program running you should:
> 1) rename disp
> disp is already a Stata build-in command.
>
> 2) Not use ereturn post b V
> You do not have a matrix b so you can not ereturn it.
>
> This should do what I think that you have in mind:
>
> program disp2, eclass
>         matrix betass=e(b)
>         matrix colnames betass = "aa" "bb" "cc" "DD" "ee" "ff"
>         mat list betass
>         ereturn repost b= betass, rename
> end

2013/1/23 Johannes Breckenfelder <Johannes.Breckenfelder@hhs.se>:

>> I would like to create a multi-column table with outreg2 from stored
>> estimates. There are no labels stored with the estimates, just the b
>> V. For each stored set of estimates, I run:
>>
>>
>>
>> program disp, eclass
>>
>>                              ereturn post b V
>>
>>                              matrix betass=e(b)
>>
>>                              matrix colnames betass = "aa" "bb" "cc" "DD"
>> "ee" "ff"
>>
>>                              mat list betass
>>
>>                              ereturn repost b = betass, rename
>>
>> end
>>
>>
>>
>> Every step seems to produce the desired outcome, except the last one:
>> ereturn repost b = betass, rename.
>>
>>
>>
>> Where is my coding/conceptual error?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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