I rewrote the question to make it reproducible. Suppose I want to maximize the function exp(alpha+eta+gamma)
for alpha,eta,gamma
along a grid of my own choice. I have done this using for-loops but I want to make use of apply-functions to speed up the procedure. Here's what I have done (eta and gamma is here being held fixed).
eta=0.11
gamma=0.06
alpha=0.5
alpha_vals=seq(0.1,1,by=0.1)
eta_vals=eta
gamma_vals=gamma
ml_temp=-Inf
lapply(alpha_vals,function(alpha_v){
lapply(eta_vals,function(eta_v){
lapply(gamma_vals,function(gamma_v){
temp=exp(alpha_v+eta_v+gamma_v)
if (temp >= ml_temp) {
ml_temp=temp
mle_matrix=c(alpha_v,eta_v,gamma_v)
}
})
})
})
Outputting mle_matrix
I get 0 0 0
, so something is clearly not working. Any help is appreciated.