Displaying 2 results from an estimated 2 matches for "adjtss".
2010 May 17
0
plm(..., model="within", effect="twoways") is very slow on unablanaced data (was: Re: Regressions with fixed-effect in R)
...sponse<-plm:::pmodel.response.plm
plmr2 <-
function(x, adj=TRUE, effect="individual")
{
## fetch response and residuals
y <- pmodel.response(x, model="within", effect=effect)
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)
}
## prepare the data
set.seed(1)
n <- 2000
T <- 15
x=rnorm(T*n)
x1=runif(T*n)
fe=rep(rnorm(1*n),each=T)
id=rep(1:(1*n),each=T)
ti=rep(1:T,1*n)
e=rnor...
2010 May 11
5
Regressions with fixed-effect in R
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