Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: How to add Q stats from -wntestq- to -esttab- table (hopefully with -estadd-)


From   Richard Herron <richard.c.herron@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to add Q stats from -wntestq- to -esttab- table (hopefully with -estadd-)
Date   Sat, 17 Sep 2011 11:27:36 -0400

I am following the example for writing your own -estadd- subroutine
that I found here:
http://repec.org/bocode/e/estout/estadd.html#estadd007

Repec.org shares the associated .do file here:
http://repec.org/bocode/e/estout/estadd007b.do

On Fri, Sep 16, 2011 at 20:01, Stas Kolenikov <skolenik@gmail.com> wrote:
> On Fri, Sep 16, 2011 at 2:51 PM, Richard Herron
> <richard.c.herron@gmail.com> wrote:
>> @Stas -- Thanks for the pointers! I used -estadd- because I wanted to
>> quickly estimate the models and generate the table, although after
>> each estimation I added several lines to find Q, which made it very
>> clunky.
>>
>> I learned enough Stata programming to write my own -estadd- function to add Q.
>>
>> * ----- begin code -----
>> * my -estadd- function to calculate Box-Ljung Q
>> capture program drop estadd_Q
>> program estadd_Q, eclass
>>    tempname residuals
>>    predict `residuals', residuals
>>    wntestq `residuals'
>>    ereturn scalar Q = r(stat)
>> end
>>
>> * get data
>> webuse friedman2, clear
>> generate ln_m1 = ln(m1)
>>
>> * make some models
>> eststo clear
>> eststo: quietly arima DS4.ln_m1, ar(1) ma(2)
>> eststo: quietly arima DS4.ln_m1, ar(1) ma(1/2)
>> eststo: quietly arima DS4.ln_m1, ar(1/2) ma(2)
>> eststo: quietly arima DS4.ln_m1, ar(1/2) ma(1/2)
>> estadd Q : *
>>
>> * and create tables with -esttab-
>> esttab, stats(aic bic Q) noobslast nomtitles
>> * ----- end code -----
>>
>> It works! Any other suggestions? Thanks!
>
> I am not sure what you mean by "it works". The larger chunk of code
> you provided does not actually use -estadd_Q-. More importantly,
> -eclass- programming (commands that represent parameter estimation
> routines) has a number of requirements that your program does not
> satisfy. See [P] ereturn. (To put it informally, you are playing with
> fire here :) ).
>
> --
> Stas Kolenikov, also found at http://stas.kolenikov.name
> Small print: I use this email account for mailing lists only.
>
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index