Statalist


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

st: RE: running multiple regressions at a time and saving coeffs


From   "Newson, Roger B" <[email protected]>
To   <[email protected]>
Subject   st: RE: running multiple regressions at a time and saving coeffs
Date   Wed, 6 Feb 2008 20:52:37 -0000

Either the official Stata prefix -statsby-, or the SSC package -parmest-, can do what you need, saving the results in output Stata datasets (or resultssets). Or, if you want to save the coefficients in a generic spreadsheet format, then use the SSC packages -estout-, -outreg- or -outreg2-. All SSC packages can be downloaded from within Stata using the -ssc- command.

I hope this helps.

Roger


Roger B Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected] 
Web page: www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Adrian de la Garza
Sent: 06 February 2008 19:16
To: [email protected]
Subject: st: running multiple regressions at a time and saving coeffs

Hi!

I have a variable in my dataset called "date," which has approximately 40 different dates in it. I would like to run an OLS regression for each of these dates, and store all of the coefficients somehow (eg, in a matrix), to then compute the average and standard deviations of all these coefficients.

I know I can run all of these regressions by date if I do the following:

bys date: reg y x1 x2 x3

but then this wouldn't save my betas anywhere. So I created a loop as follows:

egen group = group(date)
forvalues i = 1/40 {
reg y x1 x2 x3 if group == `i'
matrix mat`i' = e(b)
}

So now I have these 40 vectors mat1, mat2, mat3, ... mat40; which I would like to stack in one big matrix so that I can export it to Excel or something and compute the descriptive statistics I need, but I don't know how to do this.

OR, let me know if you know of a better way of doing what I want.

Thanks a lot!

Best,
Adrian
_________________________________________________________________
Climb to the top of the charts!�Play the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan
*
*   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/



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