dear R wizards:

not important.  more a curiosity or esthetics question.

is there a way to extend the standard lm command, so that it takes a new
argument that handles fixed effects?   right now, I have (provided to me
from an expert---I would have never figured this one out):

   diffid <- function(h,id) {
       id <- as.factor(id)[, drop=TRUE]
       apply(as.matrix(h), 2, function(x) x - tapply(x,id,mean)[id]
   }

which is used as

     r= lm( diffid(y, firmid) ~ diffid(x, firmid ) )

it works, but it would be much nicer if I could just write

    r= lm( y ~ x + z, fixed.effects=firmid )

does this already exists as a package?  or has someone figured out how to
program this?

as I wrote---this is a curiosity question, not a substance question.

regards,

/iaw
----
Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com)

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to