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

st: Re: Question about regress and multiple datasets

From   "R.E. De Hoyos" <>
To   <>
Subject   st: Re: Question about regress and multiple datasets
Date   Thu, 15 Sep 2005 18:07:52 +0100


You can use -estout- to get the estimated coefficients and statistics deriving from several models into a single table. Alternatively you can use matrices , e.g. after your estimation type

mat B = e(b)

And you will put all the estimated coefficients into matrix (vector) B.

Type -ereturn list- after the estimation to find out the local macro defining the statistics you are looking for.

R.E. De Hoyos
Faculty of Economics
University of Cambridge

----- Original Message ----- From: "Pablo Gonzalez" <>
To: <>
Sent: Thursday, September 15, 2005 5:54 PM
Subject: st: Question about regress and multiple datasets

Hi everyone,

I'm having a problem with the regress function (it's not about the command
itself but with its use)and I would like to know if anyone could help
me...Basically, I have two problems that are interconnected:

1. Is it possible to retrieve the value of the coefficients directly? For
example, using the auto data example from stata:

. regress price mpg weight

Source | SS df MS Number of obs =
-------------+------------------------------ F( 2, 71) =
Model | 186321280 2 93160639.9 Prob > F =
Residual | 448744116 71 6320339.67 R-squared =
-------------+------------------------------ Adj R-squared =
Total | 635065396 73 8699525.97 Root MSE =

price | Coef. Std. Err. t P>|t| [95% Conf.
mpg | -49.51222 86.15604 -0.57 0.567 -221.3025
weight | 1.746559 .6413538 2.72 0.008 .467736
_cons | 1946.069 3597.05 0.54 0.590 -5226.245

Does anyone know a command to retriece the coefficients from the regression,
ie, the coefficient associated with mpg, weight and const? Is it possible to
retrieve the cofficients from the t-stats, R^2, etc?

2. Imagine that we have the following data set (the number of observations
for each company is actually larger than the one showed...):

Company Y X1 X2
1 y_1 x1_1 x2_1
1 y_2 x1_2 x2_2
1 y_3 x1_3 x2_3
2 y_4 x1_4 x2_4
2 y_5 x1_5 x2_5
2 y_6 x1_6 x2_6
n y_n x1_n x2_n
n y_n1 x1_n1 x2_n1
n y_n2 x1_n2 x2_n2

I need to run a regression of Y=b0+b1*X1+b2*X2 for each company in the
dataset and then retrieve the coefficients for each regression obtained (and
t-stats and R^2) for each company and put it in another dataset/table. I've
tried to use a do file with a loop function, but I'm not able to get the
stuff working (because of the problem in 1. and because STATA doesn't seem
to be able to work with several datasets/files, or I haven't been able to
find this possibility).

Thanks for any help!


* 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