#This function finds the minimum of the directional derivative for the ML estimation inside the quadratic approximation # of - loglikelihood if we "move" away from the current iterarte c_1*f_theta1 +...+ c_m*f_thetam. FindMinimMLE <- function(valfbar,valg,K,X,prec,p1,p2,grid){ #grid <- round(seq(p1*min(X),p2*K*max(X),by = prec),digits=6) #grid <- round(seq(min(X),theta0,by = prec),digits=6) l.g <- length(grid) DirecDer.vec <- grid for(i in 1:l.g){ #print(i) DirecDer.vec[i] <- DirecDerMLE(grid[i],valfbar,valg,K=K,X=X) } minval <- min(DirecDer.vec) min.rank <- min(rank(DirecDer.vec)) index <- match(min.rank,rank(DirecDer.vec)) #print(cbind(DirecDer.vec,rank(DirecDer.vec))) #cat("index",index,"\n") thetamin <- grid[index] c(thetamin,minval) }