[R] fixed effects regression

Doran, Harold HDoran at air.org
Mon Mar 22 15:08:16 CET 2010

Well, the best approach is not to model so many fixed effects. But, if you must, there are a few options. First, have you considered treating them as random effects and using a mixed effects linear model? 

If you must build such a large model matrix for the fixed effects, the best thing to do is to use some functions in the Matrix namespace to use sparse matrices. For instance,

fm <- Matrix:::lm.fit.sparse(sparse.model.matrix(~data$yourFactor), data$yourOutcomeVariable)

where data$yourFactor is the factor variable with the postal IDs and data$yourOutcomeVariable is the DV for the regression.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Roy Lowrance
Sent: Sunday, March 21, 2010 8:01 PM
To: r-help at r-project.org
Subject: [R] fixed effects regression

Hi All:

I am trying to move a model from Stata to R.

It is a linear regression model with about 90,000 indicator variables.

What is the best approach to follow in R?

- Roy

	[[alternative HTML version deleted]]

R-help at r-project.org mailing list
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