# st: Re: RE: xtreg fixed effect with time trend; constant

 From "Scott Merryman" To Subject st: Re: RE: xtreg fixed effect with time trend; constant Date Thu, 17 Jul 2003 23:35:18 -0500

```----- Original Message -----
From: "Millimet, Daniel" <millimet@mail.smu.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, July 17, 2003 9:01 AM
Subject: st: RE: xtreg fixed effect with time trend; constant

> It's probably blowing up if you code the year as, say, 1999.  Then the
> constant becomes the mean value of y fixing all X's at zero and time at
> zero.  This is "right," just not relevant.  If you plug in the average
> value of the year in the trend, you should get sensical values of y.
> Alternatively, rescale the time variable to start in year 0.
>
> Dann
>
> ----------------------------------------------------------
> Daniel L. Millimet, Assistant Professor
> Department of Economics
> Box 0496
> SMU
> Dallas, TX 75275-0496
> Phone: 214.768.3269
> Fax:      214.768.1821
> http://faculty.smu.edu/millimet
> ----------------------------------------------------------
>
> > -----Original Message-----
> > From: david reinstein [mailto:daaronr@yahoo.com]
> > Sent: Thursday, July 17, 2003 4:37 AM
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: xtreg fixed effect with time trend; constant
> >
> > I try to do an xtreg fixed effect  including a
> > variable that represents the year of the data
> > observation.  I assume the coefficient on this should
> > be an an average time trend.  The coefficients I get
> > are plausible, but the "constant" blows up weirdly --
> > to a level much higher (or lower) than the average of
> > the dependent variable could possibly be.
> > Anyone know why?

As Dann pointed out, the constant is relatively large (or small) simply
because you've scaled up the time trend (the constant = mean(Y) - b*mean(X);
in your case the mean(X) is large).  However, I believe both forms are right
and relevant and give you the correct average of the dependent variable.

Example:

. use http://www.stata-press.com/data/r8/grunfeld.dta

. xtsum time year

Variable         |      Mean   Std. Dev.       Min        Max |
Observations
-----------------+--------------------------------------------+-------------
---
time     overall |      10.5   5.780751          1         20 |     N =
200
between |                    0       10.5       10.5 |     n =
10
within  |             5.780751          1         20 |     T =
20
|                                            |
year     overall |    1944.5   5.780751       1935       1954 |     N =
200
between |                    0     1944.5     1944.5 |     n =
10
within  |             5.780751       1935       1954 |     T =
20

So, both year and time are trends with the former starting at 1935 going to
1954 and the later starting at 1 going to 20.

. xtreg inve time, fe

Fixed-effects (within) regression               Number of obs      =
200
Group variable (i): company                     Number of groups   =
10

R-sq:  within  = 0.2121                         Obs per group: min =
20
between = 0.0000                                        avg =
20.0
overall = 0.0509                                        max =
20

F(1,189)           =
50.88
corr(u_i, Xb)  = -0.0000                        Prob > F           =
0.0000

----------------------------------------------------------------------------
--
invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
time |    8.46052   1.186155     7.13   0.000     6.120716
10.80032
_cons |   57.12279   14.20913     4.02   0.000     29.09394
85.15165
-------------+--------------------------------------------------------------
--
sigma_u |  198.82421
sigma_e |  96.728022
rho |    .808615   (fraction of variance due to u_i)
----------------------------------------------------------------------------
--
F test that all u_i=0:     F(9, 189) =    84.50              Prob > F =
0.0000

If the time coefficient is multipled by its average and added to the
constant we get the average value of the dependent variable, investment.

. disp 10.5*_b[time] + _b[_cons]
145.95825

And we get the same values if we use the year variable rather than the time
variable.

. xtreg inve year, fe

Fixed-effects (within) regression               Number of obs      =
200
Group variable (i): company                     Number of groups   =
10

R-sq:  within  = 0.2121                         Obs per group: min =
20
between =      .                                        avg =
20.0
overall = 0.0509                                        max =
20

F(1,189)           =
50.88
corr(u_i, Xb)  = -0.0000                        Prob > F           =
0.0000

----------------------------------------------------------------------------
--
invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
year |    8.46052   1.186155     7.13   0.000     6.120716
10.80032
_cons |  -16305.52   2306.489    -7.07
0.000    -20855.29   -11755.75
-------------+--------------------------------------------------------------
--
sigma_u |  198.82421
sigma_e |  96.728022
rho |    .808615   (fraction of variance due to u_i)
----------------------------------------------------------------------------
--
F test that all u_i=0:     F(9, 189) =    84.50              Prob > F =
0.0000

. disp 1944.5*_b[year] + _b[_cons]
145.95825

This is equal to the average of the dependent variable

. xtreg inve , fe

Fixed-effects (within) regression               Number of obs      =
200
Group variable (i): company                     Number of groups   =
10

R-sq:  within  = 0.0000                         Obs per group: min =
20
between =      .                                        avg =
20.0
overall = 0.0000                                        max =
20

F(0,190)           =
0.00
corr(u_i, Xb)  = 0.0000                         Prob > F           =
.

----------------------------------------------------------------------------
--
invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
_cons |   145.9583   7.685174    18.99   0.000      130.799
161.1175
-------------+--------------------------------------------------------------
--
sigma_u |  198.82421
sigma_e |  108.68477
rho |  .76993402   (fraction of variance due to u_i)
----------------------------------------------------------------------------
--
F test that all u_i=0:     F(9, 190) =    66.93              Prob > F =
0.0000

Or,

. sum invest

Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
invest |       200    145.9583    216.8753        .93     1486.7

> > Anyone know how to impose a time trend (or better,
> > several time trends for several subgroups) within the
> > context of a panel FE model?
> > Thanks,
> > David
> >

To generate a time trend for each group you can use the -xi- command: xi
i.company*time

Hope this helps,
Scott

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