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]

st: Re: st: Re: st: Re: st: Re: st: Re: st: From: Rodrigo Briceño <[email protected]>


From   Joerg Luedicke <[email protected]>
To   [email protected]
Subject   st: Re: st: Re: st: Re: st: Re: st: Re: st: From: Rodrigo Briceño <[email protected]>
Date   Wed, 26 Sep 2012 18:15:45 -0400

If I understand this correctly you need to place the call to estout
(and the -drop- command) inside the foreach loop.

So instead of:

<snip>
                drop ehat
                estimates store m`i'_`j', title (m`i'_`j')
                }
}
estout * using mod`i'_`j'.txt, cells(b(star fmt(%9.3f)) p(fmt(%9.3f)))
starlevels(* .10 ** .05 *** .01) stats(r2 N hettest hetp bgchi2s
bgchi2p jb jbp, fmt(%9.3f %9.0g %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f)
labels(R-squared)) legend label collabels(none) varlabels(_cons
Constant)
drop _est*
 try:

                drop ehat
                estimates store m`i'_`j', title (m`i'_`j')
                }
estout * using mod`i'_`j'.txt, cells(b(star fmt(%9.3f)) p(fmt(%9.3f)))
starlevels(* .10 ** .05 *** .01) stats(r2 N hettest hetp bgchi2s
bgchi2p jb jbp, fmt(%9.3f %9.0g %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f)
labels(R-squared)) legend label collabels(none) varlabels(_cons
Constant)
drop _est*
}

J.

On Wed, Sep 26, 2012 at 4:42 PM, Rodrigo Briceño <[email protected]> wrote:
> Following Nick recommendations the final code I got was the presented
> below. The suggested code for Breusch-Godfrey test didn't work, so I
> stayed with the use of a matrix to hold constants (it was suggested
> "estadd scalar bgchi2s =r(chi2)" but it didn't work since
> Breusch-Godfrey test produces the results on a matrix format).
>
> However I have an additional doubt. I think that I'm making a mistake
> when collecting the results of my regressions. My desired result is to
> have 11 txt files, each one with 24 regressions. Using the code pasted
> at the end of my mail I get only 1 txt file with all the regressions.
> I tried moving the site where the estout call is placed but no
> favorable results.
>
> Please notice that I'm using ivhettest (Mark E Schafferm) for testing
> heteroskedasticity, estout and estadd (Ben Jann) for presenting
> regression results in the form of a table.
>
> thanks.
>
> local X "sfid liqmk dv pprom"
> foreach j in 8 225 29 220 18 251 222 221 224 24 276{
>
>         forvalues i=1(1)24 {
>                 regress liq  `X' l`i'.liq if isin==`j'
>                 predict ehat if e(sample), res
>
>                 ivhettest, ivsq
>                 estadd scalar hettest = r(nr2)
>                 estadd scalar hetp = r(nr2p)
>
>                 estat bgodfrey, lags(1)
>                 matrix bgchi2s = r(chi2)
>                 matrix bgchi2p = r(p)
>                 estadd scalar bgchi2s = bgchi2s[1,1]
>                 estadd scalar bgchi2p = bgchi2p[1,1]
>
>                 su ehat, detail
>                 estadd scalar jb = (r(N)/6)*((r(skewness)^2 + (r(kurtosis) - 3)^2)/4)
>                 scalar work = (r(N)/6)*((r(skewness)^2 + (r(kurtosis) - 3)^2)/4)
>                 estadd scalar jbp = chiprob(2, work)
>
>                 drop ehat
>                 estimates store m`i'_`j', title (m`i'_`j')
>                 }
> }
> estout * using mod`i'_`j'.txt, cells(b(star fmt(%9.3f)) p(fmt(%9.3f)))
> starlevels(* .10 ** .05 *** .01) stats(r2 N hettest hetp bgchi2s
> bgchi2p jb jbp, fmt(%9.3f %9.0g %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f)
> labels(R-squared)) legend label collabels(none) varlabels(_cons
> Constant)
> drop _est*
>
>
> 2012/9/25 Nick Cox <[email protected]>:
>> I commented on this in my earlier post, but it's a prominent request
>> in the Statalist FAQ:
>>
>> http://www.stata.com/support/faqs/resources/statalist-faq/#stata
>>
>> "Say what command(s) you are using. If they are not part of official
>> Stata, say where they came from: the STB/SJ, SSC, or other archives.
>> For more explanation, see 8. Ado-files FAQ below."
>>
>> You should give enough information for anyone else to be able to
>> download the program easily.
>>
>> Note that giving the program's author alone is not informative, as
>> readers still need to know _where_ the program files are to be found.
>>
>> Nick
>>
>> On Tue, Sep 25, 2012 at 6:25 PM, Rodrigo Briceño <[email protected]> wrote:
>>> Thanks, when you say: "you are asked to explain where they come from"
>>> you mean to introduce a note in the syntax in order to locate or
>>> understand what they do?
>>>
>>> 2012/9/25 Nick Cox <[email protected]>:
>>>> -ivhettest- is also user-written.
>>>>
>>>> On Tue, Sep 25, 2012 at 6:06 PM, Nick Cox <[email protected]> wrote:
>>>>>
>>>>> 0. You use -estout- and -estadd-, which are user-written programs, so
>>>>> you are asked to explain where they come from.
>>>> *
>>
>> *
>> *   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/
>
>
>
> --
> Rodrigo Briceño
> Economist
> [email protected]
> MSN: [email protected]
> SKYPE: rbriceno1087
>
> *
> *   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/


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