# initcomputeMLE: functions to calculate initial NPMLE of the distribution In interval: Weighted Logrank Tests and NPMLE for interval censored data

## Description

The function `icfit` calculates the NPMLE of a distribution for interval censored data using an E-M algorithm with polishing and checking the Kuhn-Tucker conditions (see `icfit` help details). It allows functions for the initfit option in order to calculate the starting value of the distribution in the E-M algorithm. Because `icfit` checks the Kuhn-Tucker conditions, we can try functions without doing extensive quality control, since if the starting distribution is not close to the true NPMLE the only downside is a slower convergence. But if the initfit function is the true NPMLE then convergence happens on the first iteration. Functions must input 5 objects, L,R, Lin, Rin, and A, but need not use all of them.

## Usage

 ```1 2``` ```initcomputeMLE(L,R,Lin,Rin,A=NULL,max.inner=10,max.outer=1000,tol=1e-9) initEMICM(L=NULL,R=NULL,Lin=NULL,Rin=NULL,A=NULL,maxiter=1000,tol=1e-7) ```

## Arguments

 `L` numeric vector of left endpoints of censoring interval (equivalent to first element of Surv when type='interval2', see `icfit` details) `R` numeric vector of right endpoints of censoring interval (equivalent to second element of Surv function when type='interval2', see `icfit` details) `Lin` logical vector, should L be included in the interval? (see `icfit` details) `Rin` logical vector, should R be included in the interval? (see `icfit` details) `A` clique matrix `max.inner` see `computeMLE` `max.outer` see `computeMLE` `tol` see either `computeMLE` or `EMICM` `maxiter` see `EMICM`

## Details

In order to work correctly within `icfit` the function should output a list with at least a 'pf' element giving the estimated mass of the distribution for a series of intervals. Further, if an 'intmap' element is included (describing the series of intervals) it will be used by `icfit`.

## Value

The function `initcomputeMLE` outputs an icfit object with 'pf' and 'intmap' values and some other values defined in the help for `computeMLE`.

The function `initEMICM` outputs an icsurv object with a 'pf' element but no 'intmap' element, in addition to some other values defined in the help for `EMICM`.

Here we define pf and intmap:

 `pf` vector of estimated probabilities of the distribution `intmap` 2 by k matrix, where the ith column defines an interval corresponding to the probability, pf[i]

## Warning

In rare cases the `computeMLE` function (and hence the `initcomputeMLE` function) can cause R to crash (at least for version 0.1-3 of the `MLEcens` package).

## Author(s)

The wrappers for the functions were written by M. Fay, but the real work are the calculation engines:

The calculation engine for `initcomputeMLE` is `computeMLE` and was written by Marloes Maathuis, with part of the code for the optimization step is adapted from code that was written by Piet Groeneboom.

The calculation engine for `initEMICM` is `EMICM` and was written by Alain Vandal and Robert Gentleman

`icfit`, `computeMLE`, `EMICM`
 ```1 2 3 4 5 6``` ```## If you want speed and trust the MLEcens package, then there is no need to use icfit at all ## (but the convergence checks in icfit do not take much additional time) data(bcos) fit<-initcomputeMLE(bcos\$left,bcos\$right) summary(fit) plot(fit) ```