\HeaderA{coxph.detail}{Details of a Cox Model Fit}{coxph.detail}
\keyword{survival}{coxph.detail}
\begin{Description}\relax
Details of a Cox model fit.
Returns the individual contributions to the first and second derivative
matrix, at each unique event time.
\end{Description}
\begin{Usage}
\begin{verbatim}
coxph.detail(object)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] a Cox model object, i.e., the result of \code{coxph}.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function may be useful for those who wish to investigate new methods or
extensions to the Cox model.  The example below shows one way to calculate
the Schoenfeld residuals.
\end{Details}
\begin{Value}
a list with components

\begin{ldescription}
\item[\code{time}] the vector of unique event times

\item[\code{nevent}] the number of events at each of these time points.

\item[\code{means}] a matrix with one row for each event time and one column for each variable
in the Cox model, containing the weighted mean of the variable at that time,
over all subjects still at risk at that time.  The weights are the risk
weights \code{exp(x \%*\% fit\$coef)}.

\item[\code{nrisk}] number of subjects at risk.

\item[\code{hazard}] the hazard increment.

\item[\code{score}] the contribution to the score vector (first derivative of the log
partial likelihood) at each time point.

\item[\code{imat}] the contribution to the information matrix (second derivative of the
log partial likelihood) at each time point.

\item[\code{varhaz}] the variance of the hazard increment.

\item[\code{x,y}] copies of the input data.

\item[\code{strata}] only present for a stratified Cox model, this is
a table giving the number of time points of component \code{time} that
were contributed by each of the strata.

\end{ldescription}
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{coxph}{coxph}}, \code{\LinkA{residuals.coxph}{residuals.coxph}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
fit   <- coxph(Surv(futime,fustat) ~ age + rx + ecog.ps, ovarian, x=TRUE)
fitd  <- coxph.detail(fit)
events <- fit$y[,2]==1
etime  <- fit$y[events,1]   #the event times --- may have duplicates
indx   <- match(etime, fitd$time)
sresid <- fit$x[events,] - fitd$means[indx,]
\end{ExampleCode}
\end{Examples}

