Given an stpm2
fit and an optional list of new data, return predictions
# S4 method for stpm2
predict(object, newdata=NULL,
type=c("surv","cumhaz","hazard","density","hr","sdiff",
"hdiff","loghazard","link","meansurv","meansurvdiff",
"odds","or","margsurv","marghaz","marghr","meanhaz"),
grid=FALSE,seqLength=300,
se.fit=FALSE,link=NULL,exposed=incrVar(var),var,...)
# S4 method for pstpm2
predict(object, newdata=NULL,
type=c("surv","cumhaz","hazard","density","hr","sdiff",
"hdiff","loghazard","link","meansurv","meansurvdiff",
"odds","or","margsurv","marghaz","marghr","meanhaz"),
grid=FALSE,seqLength=300,
se.fit=FALSE,link=NULL,exposed=incrVar(var),var,...)
an stpm2
or pstpm2
object
optional list of new data (required if type in
("hr","sdiff","hdiff","meansurvdiff","or")). For type in
("hr","sdiff","hdiff","meansurvdiff","or"), this defines the unexposed
newdata. This can be combined with grid
to get a
regular set of event times (i.e. newdata would not
include the event times).
specify the type of prediction:
"surv"survival probabilities
"cumhaz"cumulative hazard
"hazard"hazard
"density"density
"hr"hazard ratio
"sdiff"survival difference
"hdiff"hazard difference
"loghazard"log hazards
"meansurv"mean survival
"meansurvdiff"mean survival difference
"odds"odds
"or"odds ratio
"margsurv"marginal (population) survival
"marghaz"marginal (population) hazard
"marghr"marginal (population) hazard ratio
"meanhaz"mean hazard
whether to merge newdata with a regular sequence of event times (default=FALSE)
length of the sequence used when grid=TRUE
whether to calculate confidence intervals (default=FALSE)
allows a different link for the confidence interval calculation (default=NULL, such that switch(type,surv="cloglog",cumhaz="log",hazard="log",hr="log",sdiff="I", hdiff="I",loghazard="I",link="I",odds="log",or="log",margsurv="cloglog", marghaz="log",marghr="log"))
a function that takes newdata and returns a transformed data-frame for those exposed (defaults to incrementing ``var'')
specify the variable name or names for the exposed/unexposed (names are given as characters)
additional arguments (for generic compatibility)
A data-frame with components Estimate
, lower
and
upper
, with an attribute "newdata" for the newdata
data-frame.
an stpm2
fit
The confidence interval estimation is based on the delta method using numerical differentiation.