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

st: Re: HELP! Output Reg Results into one Column


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: HELP! Output Reg Results into one Column
Date   Wed, 19 Jan 2005 08:51:47 -0500

It's not clear what you mean -- your title implies that you want a single variable with the coefficients in order (and without the constant). I'm not sure why you want this and think you may want to to tell us more of the big picture, but here are two ways to do it, after issuing the command -reg y x1 x2 x3-

First approach:
gen coeffs=_b[x1] in 1
replace coeffs=_b[x2] in 2
replace coeffs=_b[x3] in 3

Second Approach:

mat coef=e(b)'
svmat coef

This second approach will create a variable named coef1 that includes the 3 coefficients in order and then the constant.

If you wanted separate variables to hold the coefficients, then you might want to either write a loop or use -statsby- and -merge- the resulting dataset back in. You may need to be more specific if

Michael Blasnik
[email protected]

----- Original Message ----- From: "Nomoreno" <[email protected]>
To: <[email protected]>
Sent: Tuesday, January 18, 2005 10:58 PM
Subject: st: HELP! Output Reg Results into one Column



Dear all,

I am running into a STATA programming problem and I hope you could
provide some insights to resolve my problem.

Basically, I would like to obtain a variable that contains all the
coefficient estimates of a regression. For example, after I do "reg y x1
x2 x3", how can I generate a variable in the STATA memory that contains
all the coefficient estimates, namely b1, b2 and b3? I tried to search
the listsev archive but I do not find any relevant post.

Thank you very much. I would greatly appreciate your timely reply.

Best regards,
Simon
*
*   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