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 <landronim...@gmail.com>
To: Daniel Malter <dan...@umd.edu>
Cc: r-help@r-project.org
Subject: Re: [R] Regressions with fixed-effect in R
Message-ID:
        <aanlktikvi6_-qvh-odr31eiippuq1sra0-qconqzh...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Dear Daniel

On 5/11/10, Daniel Malter <dan...@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

--------------------------------

Giovanni Millo
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4, 
34132 Trieste (Italy)
tel. +39 040 671184 
fax  +39 040 671160 

______________________________________________
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