This program uses EM algorithm to compute the maximized (wrt p_i) empirical log likelihood function for left truncated data with the MEAN constraint:
∑ p_i f(x_i) = \int f(t) dF(t) = μ ~.
Where p_i = Δ F(x_i) is a probability. μ is a given constant. It also returns those p_i and the p_i without constraint, the LyndenBell estimator.
The log likelihood been maximized is
∑_{i=1}^n \log \frac{Δ F(x_i)}{1F(y_i)} .
1  el.trun.test(y,x,fun=function(t){t},mu,maxit=20,error=1e9)

y 
a vector containing the left truncation times. 
x 
a vector containing the survival times. truncation means x>y. 
fun 
a continuous (weight) function used to calculate
the mean as in H_0.

mu 
a real number used in the constraint, mean value of f(X). 
error 
an optional positive real number specifying the tolerance of iteration error. This is the bound of the L_1 norm of the difference of two successive weights. 
maxit 
an optional integer, used to control maximum number of iterations. 
This implementation is all in R and have several forloops in it. A faster version would use C to do the forloop part. But it seems faster enough and is easier to port to Splus.
When the given constants μ is too far away from the NPMLE, there will be no distribution satisfy the constraint. In this case the computation will stop. The 2 Log empirical likelihood ratio should be infinite.
The constant mu
must be inside
( \min f(x_i) , \max f(x_i) )
for the computation to continue.
It is always true that the NPMLE values are feasible. So when the
computation stops, try move the mu
closer
to the NPMLE —
∑_{d_i=1} p_i^0 f(x_i)
p_i^0 taken to be the jumps of the NPMLE of CDF.
Or use a different fun
.
A list with the following components:
"2LLR" 
the maximized empirical log likelihood ratio under the constraint. 
NPMLE 
jumps of NPMLE of CDF at ordered x. 
NPMLEmu 
same jumps but for constrained NPMLE. 
Mai Zhou
Zhou, M. (2005). Empirical likelihood ratio with arbitrary censored/truncated data by EM algorithm. Journal of Computational and Graphical Statistics, 14, 643656.
Li, G. (1995). Nonparametric likelihood ratio estimation of probabilities for truncated data. JASA 90, 9971003.
Turnbull (1976). The empirical distribution function with arbitrarily grouped, censored and truncated data. JRSS B 38, 290295.
1 2 3 4 5  ## example with tied observations
vet < c(30, 384, 4, 54, 13, 123, 97, 153, 59, 117, 16, 151, 22, 56, 21, 18,
139, 20, 31, 52, 287, 18, 51, 122, 27, 54, 7, 63, 392, 10)
vetstart < c(0,60,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
el.trun.test(vetstart, vet, mu=80, maxit=15)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.