data <- data.frame( x = c(0.53495, 0.33676, 0.59671, 1.28840, 0.28603, 0.18338, 0.15082, 0.42654, 0.81693, 0.69833, 0.93841, 0.06836, 0.92658, 0.39314, 0.08227, 0.83003, 0.05288, 0.60613, 0.60410, 1.21632, 0.62962, 0.03493, 1.48802, 0.51257, 1.03245, 0.15208, 0.12643, 0.17467, 0.41677, 0.66373, 1.05877, 0.24880, 0.20516, 0.70610, 0.01899, 0.45714, 0.51985, 0.73178, 0.09021, 0.26240, 0.24517, 0.06909, 0.06497, 0.57614, 0.52521, 0.21695, 0.01568, 0.76230, 0.84435, 0.33877)) attach(data) nloglike <-function(lam,x) { cutoff<-1.5 -length(x)*log(lam)+lam*sum(x)+length(x)*lam*cutoff } # produce a data vector x truncexp.mle <-function(x) { cutoff<-1.5 xbar <- mean(x) lam0<-(1/length(x))*sum(x)+cutoff*(1/(exp(cutoff/xbar)-1)) res<-nlm(nloglike,lam0,x=x) list(lam = res$estimate[1],loglik = -res$minimum) } cutoff<-1.5 final.est<-truncexp.mle(x) final.est