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

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

From   "Martin Weiss" <>
To   <>
Subject   st: AW: running multiple regressions at a time and saving coeffs
Date   Wed, 6 Feb 2008 20:49:20 +0100

help postfile, help post, help postclose, help postutil

would be my recommendation. I used to worry a lot about the problem you are
describing till I found these. (Guess the subscription to the Stata Journal
has already paid for itself...)

Warm regards,
Martin Weiss

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen

Fon: 0049-7071-2978184




-----Ursprüngliche Nachricht-----
[] Im Auftrag von Adrian de la
Gesendet: Mittwoch, 6. Februar 2008 20:16
Betreff: st: running multiple regressions at a time and saving coeffs


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

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!

Climb to the top of the charts! Play the word scramble challenge with star
*   For searches and help try:

*   For searches and help try:

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