[R] fixed effects linear model in R

Francesco cariboupad at gmx.fr
Thu Feb 9 10:56:52 CET 2012


Dear Andrew,

Thanks for your suggestion.
I will indeed have a look at Allison's booklet...

Best,

On 7 February 2012 23:39, Andrew Miles <rstuff.miles at gmail.com> wrote:
> Based on Paul Allison's booklet "Fixed Effect Regression Models" (2009), the
> FE model can be estimated by person-mean centering all of your variables
> (but not the outcome), and then including a random intercept for each
> person.  The centering gives you the FE model estimates, and the random
> intercept adjusts the standard errors for clustering by individuals.  Note
> that your data must be in person-period (or long) format to do this.
>
> In case you are unfamiliar with person-mean centering, that simply means
> taking the mean of each person's values for a given variable for all of the
> periods in your data, and then calculating a deviation from that mean at
> each time period.  For example, a person's average income over four years
> might be $50,000, but in each year their actual income would be slightly
> higher or lower than this (these would be the person-mean deviations).  In
> symbolic form, your code might look something like this:
>
> library(lme4)
> variable_pmcentered = variable - person_mean
> mod = lmer(outcome ~ variable_pmcentered + person_mean + other predictors +
> (1|personID))
>
> The advantage of this method (which Allison calls a "hybrid" method) over
> traditional FE models is that you get the benefits of a FE model
> (subtracting out time-invariant omitted variables) along with the benefits
> of random effect models (e.g., estimating coefficients for time-invariant
> variables, estimating interactions with time, letting intercepts and slopes
> varying randomly, etc.)  See Allison's booklet for more details on this
> method.
>
> Allison, Paul D. 2009. Fixed Effects Regression Models. Los Angeles, C.A.:
> Sage.
>
>
> Andrew Miles
>
>
> On Feb 7, 2012, at 5:00 PM, cariboupad at gmx.fr wrote:
>
> Dear R-helpers,
>
> First of all, sorry for those who have (eventually) already received that
> request.
> The mail has been bumped several times, so I am not sure the list has
> received it... and I need help (if you have time)! ;-)
>
> I have a very simple question and I really hope that someone could help me
>
> I would like to estimate a simple fixed effect regression model with
> clustered standard errors by individuals.
> For those using Stata, the counterpart would be xtreg with the "fe" option,
> or areg with the "absorb" option and in both case the clustering is achieved
> with "vce(cluster id)"
>
> My question is : how could I do that with R ?
> An important point is that I have too many individuals, therefore I cannot
> include dummies and should use the demeaning "usual" procedure.
> I tried with the plm package with the "within" option, but R quikcly tells
> me that the memory limits are attained (I have over 10go ram!) while the
> dataset is only 700mo (about 50 000 individuals, highly unbalanced)
> I dont understand... plm do indeed demean the data so the computation should
> be fast and light enough... and instead it saturates my memory and do not
> converge...
>
> Do you have an idea ?
> Moreover, it is possible to obtain cluster robust standard errors with plm ?
>
> Are there any other solutions for fixed effects linear models (with the
> demean trick in order not to create as many dummies as individuals) ?
> Many thanks in advance ! ;)
> John
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list