Re: [R] can R do Fixed-effects (within) regression (panel data)?

From: Douglas Bates <dmbates_at_gmail.com>
Date: Sun 05 Jun 2005 - 00:35:53 EST

On 6/4/05, ronggui <0034058@fudan.edu.cn> wrote:
> i want to ask 2 questions.
>
> 1) can R do Random-effects GLS regression which i can get from Stata?
> the following result is frome Stata.can I get the alike result from R?
>
> xtreg lwage educ black hisp exper expersq married union, re
>
> Random-effects GLS regression Number of obs = 4360
> Group variable (i) : nr Number of groups = 545
>
> R-sq: within = 0.1799 Obs per group: min = 8
> between = 0.1860 avg = 8.0
> overall = 0.1830 max = 8
>
> Random effects u_i ~ Gaussian Wald chi2(14) = 957.77
> corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000
>
> ------------------------------------------------------------------------------
> lwage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> educ | .0918763 .0106597 8.62 0.000 .0709836 .1127689
> ......................
> d86 | .0919476 .0712293 1.29 0.197 -.0476592 .2315544
> d87 | .1349289 .0813135 1.66 0.097 -.0244427 .2943005
> _cons | .0235864 .1506683 0.16 0.876 -.271718 .3188907
> -------------+----------------------------------------------------------------
> sigma_u | .32460315
> sigma_e | .35099001
> rho | .46100216 (fraction of variance due to u_i)
>
>
> 2)
>
> can R do Fixed-effects (within) regression as Stata's xtreg?
>
> the followng example is from
> "Introductory Econometrics: A Modern Approach" by Jeffrey M. Wooldridge
> Chapter 14 - Advanced Panel Data Methods
>
> use http://fmwww.bc.edu/ec-p/data/wooldridge/JTRAIN
> iis fcode
> tis year
> xtreg lscrap d88 d89 grant grant_1, fe
>
> Fixed-effects (within) regression Number of obs = 162
> Group variable (i) : fcode Number of groups = 54
>
> R-sq: within = 0.2010 Obs per group: min = 3
> between = 0.0079 avg = 3.0
> overall = 0.0068 max = 3
>
> F(4,104) = 6.54
> corr(u_i, Xb) = -0.0714 Prob > F = 0.0001
>
> ------------------------------------------------------------------------------
> lscrap | Coef. Std. Err. t P>|t| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> d88 | -.0802157 .1094751 -0.73 0.465 -.2973089 .1368776
> d89 | -.2472028 .1332183 -1.86 0.066 -.5113797 .016974
> grant | -.2523149 .150629 -1.68 0.097 -.5510178 .046388
> grant_1 | -.4215895 .2102 -2.01 0.047 -.8384239 -.0047551
> _cons | .597434 .0677344 8.82 0.000 .4631142 .7317539
> -------------+----------------------------------------------------------------
> sigma_u | 1.438982
> sigma_e | .4977442
> rho | .89313867 (fraction of variance due to u_i)
> ------------------------------------------------------------------------------
> F test that all u_i=0: F(53, 104) = 24.66 Prob > F = 0.0000

I'm not sure what the models being fit by Stata are but I imagine that they correspond to models that can be fit in R by lmer (package lme4) or lme (package nlme).



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jun 05 00:40:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:22 EST