#This function calculates the directional derivative for the LS criterion. # X is an i.i.d. sample of size n generated from a K-monotone density. # Theta is the set of knots theta_1,...,theta_m. # C is the vector of the weights C_1,...,C_m corresponding to f_{theta1},...f_{theta2} DirecDer <- function(theta,X,S,C,K){ Out <- NULL J <- 0 for(i in 1:length(S)){ J <- J + C[i]*J.Func(theta,S[i],K) } Out <- (1/theta^{K-1/2})*(J-Integr.Fn(theta=theta,K=K,X=X)) Out }