Estimation of survival function for correlated recurrence time data under a Gamma Frailty model using the maximum likelihood criterion. The resulting object of class "survfitr" is plotted by ‘plot.survfitr’, before it is returned.

1 2 | ```
mlefrailty.fit(x,tvals, lambda=NULL, alpha=NULL, alpha.min, alpha.max,
tol=1e-07, maxiter=500,alpha.console=TRUE)
``` |

`x` |
a survival recurrent event object. |

`tvals` |
vector of times where the survival function can be estimated. |

`lambda` |
optional vector of baseline hazard probabilities at t (see details). Default is numdeaths/apply(AtRisk,2,sum). |

`alpha` |
optional parameter of shape and scale for the frailty distribution. If this parameter is unknown is estimate via EM algorithm. In order to obtain the convergence of this algorithm a seed is calculated (see details). |

`alpha.min` |
optional left bound of the alpha parameter in order to obtain a seed to estimate alpha parameter. Default value is 0.5. |

`alpha.max` |
optional rigth bound of the alpha parameter in order to obtain a seed to estimate alpha parameter. Default value is the maximum of distinct times of events. |

`tol` |
optional tolerance of the EM algorithm used to estimate the alpha parameter. Default is 10e-7 |

`maxiter` |
optional maximum number of iterations of the EM algorithm used to estimate the alpha parameter. Default is 500. |

`alpha.console` |
if TRUE prints in the console the estimates initial value for alpha and the alpha estimate via the EM algorithm, if FALSE not. |

The product limit estimator developed by Pe<f1>a, Strawderman and Hollander (2001) are valid when the interoccurrence times are assumed to represent an IID sample from some underlying distribution F. This assumption is clearly restrictive in biomedical applications, and one obvious generalization that allows association between interocurrence times is a frailty model.

A common and convenient choice of frailty distribution is a gamma distribution with shape and scale parameters
set equal to an unknown parameter *α*. The common marginal survival function can be written
as following

*
1-F(t)=(alpha/(alpha+Lambda_0(t))^alpha*

The parameter *α* controls the degree of association between interoccurrence
times within a unit. Pe<f1>a, Strawderman and Hollander (2001) showed that the estimation of
*α* and *Λ_0* can be obtained via the maximisation of the marginal likelihood function
and the expectation-maximisation (EM) algorithm. For details and the theory behind this
estimator, please refer to Pe<f1>a, Strawderman and Hollander (2001, JASA).

In order to obtain a good convergence, *α* is estimated previously. This
estimation is used as a initial value in the EM procedure and it's carried out by the
maximisation of the profile likelihood for *α*. In this case the arguments
of **mlefrailty.fit** function called alpha.min and alpha.max are the boundaries
of this maximisation. The maximum is obtained using the golden section search method.

If the convergence of EM algorithm is not obtained, the initial value of alpha can be used as a alpha.min argument and recalculate.

`n` |
number of unit or subjects observed. |

`m` |
vector of number of recurrences in each subject (length n). |

`failed` |
vector of number of recurrences in each subject (length n*m). Vector ordered (e.g. times of first unit, times of second unit , ..., times of n-unit). |

`censored` |
vector of times of censorship for each subject (length n). |

`numdistinct` |
number of distinct failures times. |

`distinct` |
vector of distinct failures times. |

`status` |
0 if the estimation is can be provided and 1 if not depending if alpha could be estimate or not. |

`alpha` |
parameter of Gamma Frailty Model. |

`lambda` |
Estimates of the hazard probabilities at distinct failures times. |

`survfunc` |
vector of survival estimated in distinct times. |

`tvals` |
copy of argument. |

`MLEAttvals` |
vector of survival estimated in tvals times. |

Pe<f1>a, E.A., Strawderman, R. and Hollander, M. (2001). Nonparametric
Estimation with Recurrent Event Data. *J. Amer. Statist. Assoc*
**96**, 1299-1315.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |

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.