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
MESR (multinational endogenous switching regression)Dear Statalist users Would you voluntarily give the Stata command for MESRM and how to calculate th…
Estimation of ATT and ATU for Endogenous Switching Regression ModelDear Statalist Users I am using an endogenous switching regression (ESR) model to conduct my resear…
Coefplot for coefficient of various estimatesThe following code is supposed to create a graph ( like the attached one here ) but unfortunately, I…
How to use the egen command and not set missing to zeroHi Statalist, I am using the egen rowlast command to tell me the depression scores for patients in …
sigma_u=0 in random effects modelHi all, this is my first post so please let me know if anything can be improved upon! I am conducti…
Subscribe to:
Post Comments (Atom)
0 Response to Stata not storing my matrix in Mata
Post a Comment