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
Help Reshaping/Merging dataDear all, I am using Stata 16, on mac. Here is snapshot of a piece of my dataset. I have collected d…
Table CreationHey Statalists, I have data with variable named district, hospital name and total number of cases ha…
Regression Command for pooled DataHi.. I have four countries cross section data in my sample. i regressed separate regression for each…
Generating residuals with miHi all, On p. 296 of the Stata 16 MI manual, the following is stated: The MI predictions shoul…
F-statistics so high.Hi. I'm PhD student. I have problem to analyze my result. Can i know, why F-statistics is so big. It…
Subscribe to:
Post Comments (Atom)
0 Response to Nested Optimization on Mata
Post a Comment