# This function calculates the directional derivative of the quadratic approximation of -loglikelihood at some point theta. #Sbar and Cbar are respectively the set of support points and the weights of the current iterate fbar (outside the quadratic #approximation of -loglikelihood). # valfbar, valg are respectively the vectors storing [fbar(X_(1)),...fbar(X_(n))] and [g(X_(1)),...g(X_(n))] DirecDerMLE <- function(theta,valfbar,valg,K,X){ C1 <- NULL C2 <- NULL #Xs <- sort(X) n <- length(X) Vec.theta <- (K/(theta)^K)*ifelse(theta >= X,(theta-X)^{K-1},0) C1 <- 1- 2*mean(Vec.theta/valfbar) + mean(valg*Vec.theta/valfbar^2) C2 <- mean((Vec.theta/valfbar)^2) DirecDer <- C1/sqrt(C2) DirecDer }