This code computes a Nelson Aalen estimator. 
Inputs MUST be sorted! The last obs may need to be redefined to uncensored. 
The sorting of the data can be done by dataclean() as in the 
KapMei() function.



"SimpleNA"<-function(z, d, w=rep(1, length(z)) )
{
# w can be used to handle tied observations. (break or not break, etc) 
# For example if you want to treat z1=z2 as a real tie, (with d1=d2=1)
# then you should remove z2, d2 and w2 but make w1=2. 
# The default is to treat ties as not real tie but from rounding.

      n <- length(z) 
      if(n < 2) stop("times vector, z, is shorter then 2!")
      if(length(d) != n) stop("inputs d must be of same length")
      if(length(w) != n) stop("inputs must be of same length")
      if(any((d!=0)&(d!=1))) stop("d must be 0/1's for censor/not-censor")
      if( !is.numeric(z) ) stop("z must be numeric")

        var <- Hti <- jum <- rep(0, n)
        risk <- rev( cumsum(rev(w) ) )
        if(d[1] == 1) {
                Hti[1] <- w[1]/risk[1] 
                jum[1] <- Hti[1]
                var[1] <- w[1]/(risk[1])^2
	}
        if(n < 2) stop("warning: only one distinct time in z?")
	for(i in 2:n)
		if(d[i] == 0) {
			Hti[i] <- Hti[i - 1]
                        var[i] <- var[i - 1]
		}
		else {
		     jum[i] <- w[i]/risk[i]
		     Hti[i] <- Hti[i - 1] + jum[i]
                     var[i] <- var[i - 1] + w[i]/(risk[i])^2
		}
      list(time = z, Hazard = Hti, jump = jum, Var = var)
}

Another possibility is to use the function DnR() inside the emplik package.
It is an internal function, it gives all the risk set and failure counts.
and it can take the left truncated data. (it also can take weights)

SO the jumps of the Nelson-Aalen is just  n.event/n.risk
and the Nelson-Aalen itself is cumsum( jumps )

