my table kinda looks like this:
date factor1 factor2 factor3
1973-01-31 3.112309 1.011383 NA
1973-02-28 2.120466 11.021701 NA
1973-03-31 1.125156 0.030822 1.011383
1973-04-30 11.135342 1.067682 1.067682
1973-05-31 NA -1.069136 1.071959
1973-06-30 1.139889 1.071959 1.034
I am trying to calculate the t-value testing the hypothesis that the mean of each column is equal to zero using the NeweyWest method.
coeftest(lm(data~1), vcov = NeweyWest(lm(data~1), lag = 6, prewhite = F, adjust = T))
However, I always receive the error code:
Error in dimnames(x) <- dn :
length of 'dimnames' [1] not equal to array extent
I am pretty sure this is due to the NAs in my table. I tried to use na.action
of the lm
function. However, this did not work. I can calculate the t-value for each column individually but I am looking for a solution to calculate the t-value for the whole table at once since it is a huge table. Does anyone have an idea to solve my problem? I am very thankful for every hint.