Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Saving multiple parameter estimates


From   Ulrich Kohler <kohler@wz-berlin.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Saving multiple parameter estimates
Date   Tue, 2 Dec 2003 11:22:36 +0100

Patrick Mcelduff wrote:
> I have a dataset with repeat measures on 150 individuals. I want to
> fit a linear regression for each individual (to be used in a
> subsequent analysis). How can I save the slope coefficients for
> each of the 150 regressions?


Use -post- for this task. The following snippet may deal as a starting point. 
It assumes that you have an identifier-variable "ID" which serially numbers 
the 150 individuals. If you haven't  such a variable create one with -egen, 
group- (or use an approach with -levels-). 

--------------------------------------------------
post xyz id coef using myfile, replace
forvalues i = 1/150 {
	regress depvar indepvar if id==`i'
	post xyz ('i') (_b[indepvar])
}
postclose xyz
----------------------------------------------------

Th code stores the coefficients of indepvar and the identifier variable in the 
Stata-file "myfile.dta". 

regards
uli














-- 
kohler@wz-berlin.de
+49 (030) 25491-361


*
*   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/



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