# st: RE: slope for each individual

 From "Maarten Buis" To Subject st: RE: slope for each individual Date Fri, 7 Apr 2006 08:34:50 +0200

```Yoshiro:
The simplest solution is to estimate the separate regressions and store the estimates, but in each regression you only use six observations. In the code below the estimates are stored in the matrix be where the first column is the district id and the second the slope.

reg population year if id == 1
mat b = 1, _b[year]
forvalues i = 2/1000{
reg population year if id == `i'
mat b = b \ `i' , _b[year]
}

HTH,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z214

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Yoshiro Nagao
Sent: vrijdag 7 april 2006 8:11
To: statalist@hsphsun2.harvard.edu
Subject: st: slope for each individual

I have such a dataset as follows:
************************************
district ID,year,population
1,1998,2000
1,1999,2010
1,2000,2020
1,2001,2030
1,2002,2040
1,2003,2050
2,1998,1000
2,1999,1010
2,2000,1020
2,2001,1030
2,2002,1040
2,2003,1050
....
1000,2002,4060
1000,2003,5000
************************************
For the each district, population
is recorded every year between
1998 and 2003.

I would like to calculate
individual "regression coefficient (slope)"
for the each district.

General slope is not of my interest.

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