I am trying to run a nested optimization routine for Empirical Likelihood with the following routine (where I am implementing a mini-max optimization routine over the function f = ln(1+lambda*g(b)), where g(b) are the moment conditions). Thus there are two sets of parameters, lambda (1 x cols(z)) and beta (1 x cols(x)). However it gives an error at the end stating 'starting values for parameters required', despite providing the starting values below. Any help would be highly appreciated,
mata:
void lambda1(todo,lambda,beta,f,S1,H)
{
real colvector y
real matrix z, x
u = y-x*beta'
m= z:*u
g = m*lambda'
f = mean(ln(1:/(1:+g)))
if (todo>=1){
S1 = -mean(m:/(1:+g))
}
}
real scalar function invda(real rowvector beta)
{
I=optimize_init()
optimize_init_evaluator(I,&lambda1())
optimize_init_evaluatortype(I,"d1")
optimize_init_params(I,J(1,cols(H),0))
optimize_init_argument(I,1,beta)
optimize_init_which(I,"max")
optimize_init_conv_maxiter(I,10000)
optimize_init_singularHmethod(I,"hybrid")
lambda=optimize(I)
a = optimize_result_value(I)
return(lambda)
}
void beta1(todo,beta,f,S2,H)
{
real colvector y
real matrix z, x
real rowvector lambda
lambda=invda(beta)
m= z:*u
g = m*lambda'
f = mean(ln(1:/(1:+g)))
if (todo>=1){
Q2 = mean(((z:*x[,1])*lambda'):/(1:+g))
Q3 = mean(((z:*x[,2])*lambda'):/(1:+g))
Q4 = mean(((z:*x[,3])*lambda'):/(1:+g))
Q5 = mean(((z:*x[,4])*lambda'):/(1:+g))
Q6 = mean(((z:*x[,5])*lambda'):/(1:+g))
S2 = Q2,Q3,Q4,Q5,Q6
}
}
S=optimize_init()
optimize_init_evaluator(S,&beta1())
optimize_init_evaluatortype(S,"d1")
optimize_init_params(S,(b0))
optimize_init_which(S,"min")
optimize_init_technique(S, "nr")
optimize_init_conv_maxiter(S,10000)
optimize_init_singularHmethod(S,"hybrid")
q=optimize(S)
q
end
Related Posts with Nested Optimization on Mata
Merging Data - Isolate non-uniquely identified observationsDear all, I am currently working on matching two databases, that entail observations on about 600'0…
Regress only on fixed effects without using dummiesI want to regress on only fixed effects to obtain dipersion of within-variation. However, I am using…
How to test coefficient equality with high dimensional fixed effect and IV?I have a panel dataset. My statistical model includes an exogenous variable X_1, an endogenous varia…
psacalc strange delta estimateGreetings, I am using the psacalc (Oster, 2017) command to estimate delta (the ration of selection …
Regress only on fixed effects (residualize) without using dummiesI want to regress on only fixed effects to obtain dipersion of within-variation. However, I am using…
Subscribe to:
Post Comments (Atom)
0 Response to Nested Optimization on Mata
Post a Comment