search for: invxx

Displaying 1 result from an estimated 1 matches for "invxx".

Did you mean: invx
2009 Feb 07
1
fixed effects regression
...l be deeply appreciated.... feols = function(y,X,id) { n = length(y); uniq_id = unique(id); n_id = length(uniq_id); dummy = matrix(rep(0,n*(n_id-1)),nrow=n); for (i in 1:(n_id-1)) dummy[id==uniq_id[i],i] = 1; X = cbind(rep(1,n),X,dummy); k = ncol(X); invXX = solve(t(X) %*% X); b = as.numeric(invXX %*% (t(X) %*% y)); res = y - X%*%b; s2 = as.numeric(t(res) %*% res /(n-k)); omega = as.numeric(s2) * invXX; se = sqrt(diag(omega)); dev = y - mean(y); r2 = 1 - as.numeric(t(res)%*%res)/as.numeric(t(dev) %*% dev); t = b/se;...