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

From |
"Paulo Regis" <pauloregis.ar@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Ado-files commands and saving results in e() |

Date |
Wed, 3 Dec 2008 17:20:38 +0800 |

Dear all, First of all, I would like to say that, previous to posting on this list, I have checked internet (not much out there, though), help files of -ereturn and -estimates. I also use "get trace on" to study what some stata commands do to display results. Section 18.10 (Saving Revults) in the User's Guide was the most useful material available. I manage my way but my general feeling is that I hope it would have been easier. Any other material you think may be useful would be welcomed. Back to business, I would like to have some comments from people of this list with more knowledge of Stata and statistics than me: what kind of results you should make available after you use a user written command. Since it is very likely your answer would be that it depends, let me present you with my particular case. I am working with some three-step procedure that requires to make some transformation of the original variable. I developed an ado-file command and I am struggling to present the coefficient table and make available results in e(). Lets say you create an ado file such as program define mycommand, eclass version 9 syntax varlist , i(panel) tokenize `varlist' local yvar="`1'" macro shift local xvarlist="`*'" ... *Step 3 xtreg `yvar_hat' `xvarlist_hat', i(`panel') fe ereturn local cmd mycommand ... end You have three local that group the information the user must provide: the dependent variable (yvar), independent variable list (xvarlist) and panel id variable (panel). I do a three step procedure (which is basically a GLS estimator) where the "_hat" locals contain the transformation of the original data. You have different results in e(): scalars, macros, matrices, functions. My programme makes available the results saved in e() by -xtreg and only changes e(cmd) which is the name of the estimation command ("mycommand" in this case). I think it is reasonable to keep the scalars and matrices from e() but I am particularly concerned about one of the macro ereturn, which is e(predict) : "xtrefe_p" Here, -xtrefe_p was created for -xtreg. It is unlikely it would be useful for my command. I use transformation of the original variables with xtreg and these auxiliary varaibles are not available any more. Other macro ereturn look fine to me. If the best option is to eliminate e(predict), the problem is how to do this which should be straightforward. The only way around I found was to use "ereturn post". The code becomes program define mycommand, eclass ... *Step 3 xtreg `yvar_hat' `xvarlist_hat', i(`panel') fe tempvar b vb esample mat `b'=e(b) mat `vb'=e(V) mat colnames `b' = `xvar' _cons mat colnames `vb' = `xvar' _cons mat rownames `vb' = `xvar' _cons gen byte `esample' = e(sample) local r2b e(r2_b) ... ereturn post `b' `vb', depname(`yvar') esample(`esample') ereturn local r2_b r2b ... ereturn local cmd mycommand ... end I can introduce additional scalar ereturn from xtreg such as e(r2_b) quite easily. My question is whether there is an easier way to get rid of "e(predict)" than using "ereturn ...post" which erase all other ereturns. Thank you for your time Paulo * * 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/

- Prev by Date:
**st: A logit approach that allows alternative specific variables** - Next by Date:
**st: RE: Simulation: Error from using -clear- in the prgram** - Previous by thread:
**st: A logit approach that allows alternative specific variables** - Next by thread:
**st: analytic standard errors in quantile regression** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |