plm function in plm package are for panel data model.> library(plm)
> ?plm
2006/8/24, Eduardo Leoni <e.leoni at gmail.com>:> Hi -
>
> I am doing an analysis using panel data methods, particularly what
> economists call "fixed effects". It can easily be done in R
through
> the inclusion of factors in an lm formula. However, when the number of
> groups is excessive (in my case 2000+) it is much more efficient to
> demean the data by panel.
>
> I created this function following Farnsworth
> (http://cran.r-project.org/doc/contrib/Farnsworth-EconometricsInR.pdf)
>
>
> demean <- function(x,index) {
> for (i in unique(index)) {
> for (j in 1:ncol(x)) {
> x.now <- x[index==i,j]
> x[index==i,j] <- x.now-mean(x.now,na.rm=TRUE)
> }
> }
> x
> }
>
> it is obvious that there must be a much much more efficient way to do
> this, though. Any recommendations?
>
> thanks,
>
> -eduardo
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>
--
??????
Department of Sociology
Fudan University