Hello,
I have a bit of a silly problem in setting up Maximum Likelihood Estimation of Fixed Effects Linear Regression Model via Optimize routine on Mata, with the corresponding (Gaussian) log-likelihood being (in a simplified setting):
L = - NT / 2 * ln(sigma) - (1/sigma)*( y_h - x_h*beta' )'*( y_h - x_h*beta')
Where y_h and x_h are within-transformed variables from individual and time Fixed Effects inclusion and sigma is variance of IID disturbance term. However running estimating the above specification via the following routine on Mata:
mata
// UnConcentrated Log Likelihood Gaussian with Fixed and Time Effects
void spml_1_UN(todo, b, lnf,g,H)
{
external ya, xa, id
paninfo = panelsetup(id,1)
npanels = rows(paninfo)
t = mean(paninfo[,2]-paninfo[,1]:+1)
sigma = b[1]
beta = b[2..cols(xa)+1]
// Fixed Effects Within transformation Operator
i = J(t,1,1)
M0 = I(t) - (1/(t))*i*i'
//End
//Time Effects Within Transformation Operator
T = I(npanels) - (1/npanels)*(J(npanels,1,1)*J(npanels,1,1)')
//End
ya1 = colshape(colshape(ya,t)*M0,1)
xa1 = J(npanels*(t),cols(xa),0)
for (k = 1; k <= cols(xa); k++) {
xa1[,k] = colshape(colshape(xa[,k],t)*M0,1)
}
ya2 = colshape(T*colshape(ya1,t),1)
xa2 = J(npanels*t),cols(xa1),0)
for (k = 1; k <= cols(xa); k++) {
xa2[,k] = colshape(T*colshape(xa1[,k],t),1)
}
lnf = - (npanels*t)/2*ln(sigma) - 1/(2*sigma)*(ya2 - xa2*beta')'*(ya2 - xa2*beta')
}
real function rho1_1_UN(xa){
S = optimize_init( )
optimize_init_evaluator(S, &spml_1_UN())
optimize_init_which(S,"max")
optimize_init_evaluatortype( S, "gf0")
optimize_init_params(S, (J(1,1+cols(xa),0)) )
optimize_init_singularHmethod(S, "hybrid")
optimize_init_conv_maxiter(S, 100)
optimize_init_technique(S, "nr")
//optimize_init_tracelevel(S, "none")
//optimize_init_conv_warning(S, "off")
a = optimize(S)
return(a)
}
end
Unfortunately the above routine consistently gives me the following message : initial values not feasible. Any help would be most welcome. While yes there are closed form estimators for the paramters above, however I would like to successfuly estimate the full unconcentrated log-likelihood.
Related Posts with Hello ! Problems in setting up Maximum Likelihood Estimation of Fixed Effects Linear Regression Model via Optimize routine on Mata
model command in endogeneity testHi. I'm using Stat 13 and need to have endogeneity test. My model is as below. I wonder whether the …
How to save HR and 95%CI and P-value from Loops of cox regression from ten exposures on same outcome in a separate file (excel or dta)Hi, I am recently working on a project that requires me to calculate the HRs and 95%CI and p-value f…
Test for assumptions of OLS and FEHi, I am making a diff-in-diff regression for the top ESG companies relative to the bottom ESG comp…
Control variablesHi, I have a question in regards control variables. I am making a diff-in-diff model to measure the…
How to set monthly panel data in stata ?Hello guys, i have monthly panel data of import and want to do regression but the problem is i dont …
Subscribe to:
Post Comments (Atom)
0 Response to Hello ! Problems in setting up Maximum Likelihood Estimation of Fixed Effects Linear Regression Model via Optimize routine on Mata
Post a Comment