\HeaderA{frailty}{(Approximate) Frailty models}{frailty}
\methaliasA{frailty.brent}{frailty}{frailty.brent}
\methaliasA{frailty.controlaic}{frailty}{frailty.controlaic}
\methaliasA{frailty.controldf}{frailty}{frailty.controldf}
\methaliasA{frailty.controlgam}{frailty}{frailty.controlgam}
\methaliasA{frailty.controlgauss}{frailty}{frailty.controlgauss}
\methaliasA{frailty.gamma}{frailty}{frailty.gamma}
\methaliasA{frailty.gammacon}{frailty}{frailty.gammacon}
\methaliasA{frailty.gaussian}{frailty}{frailty.gaussian}
\methaliasA{frailty.t}{frailty}{frailty.t}
\keyword{survival}{frailty}
\begin{Description}\relax
When included in a \LinkA{coxph}{coxph} or \LinkA{survreg}{survreg}, fits
by penalised likelihood a random effects (frailty) model. \code{frailty} is generic, with methods for t, Gaussian and Gamma distributions.
\end{Description}
\begin{Usage}
\begin{verbatim}
frailty(x, distribution="gamma", ...)
frailty.gamma(x, sparse = (nclass > 5), theta, df, eps = 1e-05, method = c("em","aic", "df", "fixed"), ...) 
frailty.gaussian(x, sparse = (nclass > 5), theta, df, method = c("reml","aic", "df", "fixed"), ...)
frailty.t(x, sparse = (nclass > 5), theta, df, eps = 1e-05, tdf = 5,method = c("aic", "df", "fixed"), ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] group indicator
\item[\code{distribution}] frailty distribution 
\item[\code{...}] Arguments for specific distribution, including (but not
limited to) 
\item[\code{sparse}] Use sparse Newton-Raphson algorithm
\item[\code{df}] Approximate degrees of freedom
\item[\code{theta}] Penalty
\item[\code{eps}] Accuracy of \code{df}
\item[\code{method}] maximisation algorithm
\item[\code{tdf}] df of t-distribution
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The penalised likelihood method is equivalent to maximum (partial)
likelihood for the gamma frailty but not for the others.

The sparse algorithm uses the diagonal of the information matrix for
the random effects, which saves a lot of space. 

The frailty distributions are really the log-t and lognormal: t and
Gaussian are random effects on the scale of the linear predictor.
\end{Details}
\begin{Value}
An object of class \code{coxph.penalty} containing a factor with attributes specifying the control functions.
\end{Value}
\begin{References}\relax
Therneau TM, Grambsch PM, Pankratz VS (2003) "Penalized
survival models and frailty" Journal of Computational and Graphical
Statistics 12, 1: 156-175
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{coxph}{coxph}},\code{\LinkA{survreg}{survreg}},\code{\LinkA{ridge}{ridge}},\code{\LinkA{pspline}{pspline}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
kfit <- coxph(Surv(time, status)~ age + sex + disease + frailty(id), kidney)
kfit0 <- coxph(Surv(time, status)~ age + sex + disease, kidney)
kfitm1 <- coxph(Surv(time,status) ~ age + sex + disease + 
                frailty(id, dist='gauss'), kidney)
coxph(Surv(time, status) ~ age + sex + frailty(id, dist='gauss', method='aic',caic=TRUE), kidney)
# uncorrected aic
coxph(Surv(time, status) ~ age + sex + frailty(id, method='aic', caic=FALSE), kidney)

rfit2a <- survreg(Surv(time, status) ~ rx +
                  frailty.gaussian(litter, df=13, sparse=FALSE), rats )
rfit2b <- survreg(Surv(time, status) ~ rx +
                  frailty.gaussian(litter, df=13, sparse=TRUE), rats )
rfit2a
rfit2b
\end{ExampleCode}
\end{Examples}

