[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Henrik Andersson" <henrik.andersson@vti.se> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: VB: RE: by with multiple commands |

Date |
Fri, 2 May 2008 18:48:07 +0200 |

Dear Nick, thanks for your help. forval does exactly what I want. Henrik -----Ursprungligt meddelande----- I don't know what you expect Stata to do with all the output that is produced separately for each -by- group. For example, do you want separate matrices b, beta, v for each group? I guess you do. It is more likely perhaps that you want to loop over the groups, something like this: egen group = group(myvar) su group, meanonly forval i = 1/`r(max)' { probit ... if group == `i' wtpcikr ... if group == `i' matrix b`i' = e(b) matrix beta`i' = b`i'/-b`i'[1,1] ... } See also FAQ . . . . . . . . . . Making foreach go through all values of a variable 8/05 Is there a way to tell Stata to try all values of a particular variable in a foreach statement without specifying them? http://www.stata.com/support/faqs/data/foreach.html SJ-2-2 pr0005 . . . . . . Speaking Stata: How to face lists with fortitude Q2/02 SJ 2(2):202--222 (no commands) demonstrates the usefulness of for, foreach, forvalues, and local macros for interactive (non programming) tasks <http://www.stata-journal.com/article.html?article=pr0005> Nick n.j.cox@durham.ac.uk Henrik Andersson I need to run identical regressions for different subsamples of my data set. I have one variable that defines the different subsamples and I would like to use this variable together with the "by" command. My problem is that my regressions contain several command. My regressions, together with my "post estimation" commands, look like probit yes lnbid lninc if bid<=income wtpcikr lnbid lninc if bid<=income, mym(mean1) expo matrix b=e(b) matrix beta=b/-b[1,1] matrix v=e(V)/(b[1,1]^2) ereturn post beta v, noclear ereturn display scalar sigma=1/-b[1,1] display sigma Using my variable that defines the different subsamples, I would like to run the string of commands above for each subsample. Is this possible using the "by" command? * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: time invariant vars and fixed effects** - Next by Date:
**RE: st: File sizes in Stata & SPSS (was Weights )** - Previous by thread:
**st: time invariant vars and fixed effects** - Next by thread:
**Re: constraints in xtgls and xtpcse [was: st: QUESTION]** - Index(es):

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