Hi all,
I am running the code of DLW (2012) with using Stata 15. The command is meant to generate a matrix. But Stata gives an error message when I call the matrix. Please find the code below:
mata:
void GMM_DLW(todo,betas,crit,g,H)
{
PHI=st_data(.,("phi"))
PHI_LAG=st_data(.,("phi_lag"))
Z=st_data(.,("const","l_lag","k"))
X=st_data(.,("const","l","k"))
X_lag=st_data(.,("const","l_lag","k_lag"))
Y=st_data(.,("y"))
C=st_data(.,("const"))
OMEGA=PHI-X*betas'
OMEGA_lag=PHI_LAG-X_lag*betas'
OMEGA_lag_pol=(C,OMEGA_lag)
g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol' OMEGA
XI=OMEGA-OMEGA_lag_pol*g_b
crit=(Z'XI)'(Z'XI)
crit
}
void DLW()
{
initialvalue=st_data(1,("blols","bkols"))
S=optimize_init()
optimize_init_evaluator(S,&GMM_DLW())
optimize_init_evaluatortype(S,"d0")
optimize_init_technique(S, "nm")
optimize_init_nmsimplexdeltas(S, 0.1)
optimize_init_which(S,"min")
optimize_init_params(S,("OLS"))
p=optimize(S)
p
st_matrix("beta_dlw",p)
}
end
cap program drop dlw
program dlw, rclass
preserve
sort fid year
mata DLW()
end
dlw
gen beta_c1=beta_dlw[1,1]
when I call dlw, Stata gives an error message :
beta_ ambiguous abbreviation
st_data(): 3598 Stata returned error
DLW(): - function returned error
<istmt>: - function returned error
when I tried to generate variables from the matrix, Stata gives an error:
beta_dlw not found
Does anyone has an idea of why Stata does not generate or store the matrix?
Related Posts with Stata not storing my matrix in Mata
Bug in margins with factor variable notation for quadratic termDescription: I think I found a bug with margins. specifically with the atmeans option. If the model…
Categorize income variable due to quartilesHello, I assume the solution is very simple, but I'm just standing at a loss.... I have to categro…
IRF in a SVAR with manually modified B matrixHello, I'm estimating a SVAR with both government spending and tax rates, as well as GDP, similar t…
How to save the predicted value of regressionsDear Statalists' Can any one help me how to save the predicted value of many regressions. I have to …
not enough memory for "merge"Dear community! I am trying two merge two files based on a facilityID which, however, is a unique i…
Subscribe to:
Post Comments (Atom)
0 Response to Stata not storing my matrix in Mata
Post a Comment