\HeaderA{predict.coxph}{Predictions for a Cox model}{predict.coxph}
\methaliasA{predict.coxph.penal}{predict.coxph}{predict.coxph.penal}
\keyword{survival}{predict.coxph}
\begin{Description}\relax
Compute fitted values and regression terms for a model fitted by
\code{\LinkA{coxph}{coxph}}
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'coxph':
predict(object, newdata,
type=c("lp", "risk", "expected", "terms"),
se.fit=FALSE, terms=names(object$assign), collapse,
safe=FALSE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] the results of a coxph fit. 

\item[\code{newdata}] Optional new data at which to do predictions.
If absent predictions are for the 
data frame used in the original fit. 

\item[\code{type}] the type of predicted value. 
Choices are the linear predictor (\code{"lp"}), the risk score exp(lp)
(\code{"risk"}), 
the expected number of events given the covariates and follow-up time 
(\code{"expected"}), and the terms of the linear predictor (\code{"terms"}). 

\item[\code{se.fit}] if TRUE, pointwise standard errors are produced for the predictions. 

\item[\code{terms}] if type="terms", this argument can be used to specify which terms should be 
included; the default is all. 

\item[\code{collapse}] optional vector of subject identifiers.  
If specified, the output will contain one entry per subject rather than one 
entry per observation. 

\item[\code{safe}] not used in R
\item[\code{...}] For future methods
\end{ldescription}
\end{Arguments}
\begin{Value}
a vector or matrix of predictions, or a list containing the predictions 
(element "fit") and their standard errors (element "se.fit") if the se.fit 
option is TRUE.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{predict}{predict}},\code{\LinkA{coxph}{coxph}},\code{\LinkA{termplot}{termplot}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
fit <- coxph(Surv(time, status) ~ age + ph.ecog + strata(inst), lung) 
mresid <- lung$status - predict(fit, type='expected') #Martingale resid 
predict(fit,type="lp")
predict(fit,type="risk")
predict(fit,type="expected")
predict(fit,type="terms")
predict(fit,type="lp",se.fit=TRUE)
predict(fit,type="risk",se.fit=TRUE)
predict(fit,type="expected",se.fit=TRUE)
predict(fit,type="terms",se.fit=TRUE)
\end{ExampleCode}
\end{Examples}

