Hey guys,
I am running a two-step joint dynamic panel GMM estimator on Mata, with the stacked formula: b = (inv(x'*z*inv(z'*(e*e')*z)*z'*x))*(x'*z*inv(z'*(e* e')*z)*z'*y), where x refers to matrix of regressors, z refers to matrix of instrumental variables and e refers to vector of (1st-Step) residuals.
For the above two step formula, for a single equation, I calculate the variance of the moment conditions (z'*(e*e')*z), (let's call it S) as first step towards deriving cross-section heteroscedasticity robust weighing matrix
k = cols(z)
st_view(id=. , . , ("id"))
info = panelsetup(id,1)
nc = rows(info)
S= J(k,k,0)
for(i=1; i<=nc; i++) {
panelsubview(zi = . , z , i , info)
panelsubview(ei = . , e , i , info)
S = S + zi'*(ei*ei')*ei
}
The problem arises since I have a large number of cross-sections in my panel dataset, which has 2941 cross-sectional units spread across 14 years. Thus the matrix S at the end of the loop is giving null values. Where am I going wrong ? On datasets with shorter cross-sectional counts, I can calculate S just fine, but in this instance the S matrix is returning null / no values. Any other way I may derive the S matrix ?
0 Response to Two - step dynamic panel GMM estimator weight Matrix returning blank value after Mata loop
Post a Comment