Hi there, Maybe people who know both R and econometrics will be able to answer my questions. I want to run panel regressions in R with fixed-effect. I know two ways to do it. First, I can include factor(grouping_variable) in my regression equation. Second, I plan to subtract group mean from my variables and run OLS panel regression with function lm(). I plan to do it with the second way because the number of groups is large, which incur computational problems inverting large model-matrix. I am interested in the R-squared and adjusted R-squared out of these regressions. Do I need to adjust my R-squared after I run OLS regressions with demeaned variables? Are there any functions that specifically deal with fixed-effects? Thanks. Best, Jia
There is the plm package for linear panel models. Further, since estimation of fixed effects models rests on the within-subject or -object variance, the R-squared of interest is typically the within R-squared, not the overall or between R-squared. Read up about it before you use it though. Daniel -- View this message in context: http://r.789695.n4.nabble.com/Regressions-with-fixed-effect-in-R-tp2173314p2173326.html Sent from the R help mailing list archive at Nabble.com.
On 5/11/10, chen jia <chen_1002 at fisher.osu.edu> wrote:> Are there any functions that specifically deal with fixed-effects? >Other than plm and its vignette, you may want to check this document [1]. Liviu [1] http://cran.r-project.org/doc/contrib/Farnsworth-EconometricsInR.pdf
Dear Daniel On 5/11/10, Daniel Malter <daniel at umd.edu> wrote:> R-squared of interest is typically the within R-squared, not the overall or >Could you point to an example on how to compute the within R-squared in R, either via lm() or plm()? Thank you Liviu
Thanks. I have the PDF document that you suggest. It is very brief on fixed-effect in panel regressions. I will look into plm package. Best, Jia On Tue, May 11, 2010 at 8:19 AM, Liviu Andronic <landronimirc at gmail.com> wrote:> On 5/11/10, chen jia <chen_1002 at fisher.osu.edu> wrote: >> ?Are there any functions that specifically deal with fixed-effects? >> > Other than plm and its vignette, you may want to check this document [1]. > Liviu > > [1] http://cran.r-project.org/doc/contrib/Farnsworth-EconometricsInR.pdf >-- Ohio State University - Finance 248 Fisher Hall 2100 Neil Ave. Columbus, Ohio 43210 Telephone: 614-292-2830 http://www.fisher.osu.edu/~chen_1002/
Dear Liviu, we're still working on measures of fit for panels. If I get you right, what you mean is the R^2 of the demeaned, or "within", regression. A quick and dirty function to do this is: pmodel.response<-plm:::pmodel.response.plm # needs this to make the method accessible r2<-function(x, adj=TRUE) { ## fetch response and residuals y <- pmodel.response(x, model="within") myres <- resid(x) n <- length(myres) if(adj) { adjssr <- x$df.residual adjtss <- n-1 } else { adjssr <- 1 adjtss <- 1 } ssr <- sum(myres^2)/adjssr tss <- sum(y^2)/adjtss return(1-ssr/tss) } and then> r2(yourmodel)Hope this helps Giovanni ------------------------------ Message: 13 Date: Tue, 11 May 2010 13:21:02 +0100 From: Liviu Andronic <landronimirc at gmail.com> To: Daniel Malter <daniel at umd.edu> Cc: r-help at r-project.org Subject: Re: [R] Regressions with fixed-effect in R Message-ID: <AANLkTikvI6_-QVH-Odr31EiipPuq1sRa0-qconQZHtAV at mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Dear Daniel On 5/11/10, Daniel Malter <daniel at umd.edu> wrote:> R-squared of interest is typically the within R-squared, not theoverall or>Could you point to an example on how to compute the within R-squared in R, either via lm() or plm()? Thank you Liviu -------------------------------- Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160
Seemingly Similar Threads
- plm(..., model="within", effect="twoways") is very slow on unablanaced data (was: Re: Regressions with fixed-effect in R)
- Attribute Length Error when Trying plm Regression
- Hausman test error solve
- Ask if an object will respond to a function or method
- plm: Hausman Test error