my problem is this: I get NA
where I need to get some values ββwhen calculating reliable standard errors.
I am trying to do a regression with a fixed effect using standard errors. For this, I follow Arai (2011) , which on p. 3 follows Stock / Watson (2006) (later published in Econometrica , for those with access). I would like to adjust the degrees of freedom by (M/(M-1)*(N-1)/(NK)
against the downward shift, since my number of clusters is finite, and I have unbalanced data.
Similar issues were posted before [ 1 , 2 ] on StackOverflow and related issues [ 3 ] on CrossValidated.
Arai (and the answer in the 1st link) uses the following code for functions (below I give my data below):
gcenter <- function(df1,group) { variables <- paste( rep("C", ncol(df1)), colnames(df1), sep=".") copydf <- df1 for (i in 1:ncol(df1)) { copydf[,i] <- df1[,i] - ave(df1[,i], group,FUN=mean)} colnames(copydf) <- variables return(cbind(df1,copydf))}
where gcenter
calculates the deviations from the mean (fixed effect). Then I continue and do the regression with DS_CODE
, which is my cluster variable (I named my data data).
centerdata <- gcenter(data, data$DS_CODE) datalm <- lm(C.L1.retE1M ~ C.MCAP_SEC + C.Impact_change + C.Mom + C.BM + C.PD + C.CashGen + C.NITA + C.PE + C.PEdummy + factor(DS_CODE), data=centerdata) M <- length(unique(data$DS_CODE)) dfcw <- datalm$df / (datalm$df - (M-1))
and want to calculate
clx(datalm, dfcw, data$DS_CODE)
However, when I want to calculate uj (see clx
formula above) for variance, I only get at the beginning some values ββfor my regressors, and then a lot of zeros. If this input uj is used for dispersion, the result is only NAs
.
My details
Since my data may have a special structure, and I cannot understand the problem, I post it all as a link Hotmail The reason is that with other data (taken from Arai (2011)) my problem does not arise. Sorry in advance for the mess, but I would really appreciate it if you could take a look at it nonetheless. The file is a 5 MB .txt file containing pure data.