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
Create a new variable based on observations within a groupHello, my dataset is structered the following: clear input float (group_id won_close_dummy loss_cl…
Define nested loops for dependent and independent variablesI have a panel data set from 1970 to 2014 on yields and prices for four different crops. I need to r…
How to add a constraint when matching using teffects psmatch, cem or psmatch2?Hello dear statalists, I am trying to match the houses sold at year t with similar houses sold in ye…
How to genearte the list of vars for nodes using nw2fromedge command when the number of nodes exceeds 1000Hello, could someone help me on this question. I am using the network analysis command "nw2fromedge"…
How to load in the vertex attributes in networkHello everyone, I am struggling to find out how to load the vertex attributes into a network? I am c…
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