Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Stas Kolenikov <skolenik@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 18:07:03 -0500 |
Oh, I see now. This is actually a subcommand of -estadd- (very much like there are subcommands of say -egen-). I was not aware of this functionality of -estadd-. I take it back, you should be fine. On Sat, Sep 17, 2011 at 10:27 AM, Richard Herron <richard.c.herron@gmail.com> wrote: > 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/ > -- 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/