predict-methods: Predicted values for an stpm2 or pstpm2 fit

predict-methodsR Documentation

Predicted values for an stpm2 or pstpm2 fit

Description

Given an stpm2 fit and an optional list of new data, return predictions

Usage


    ## S4 method for signature 'stpm2'
predict(object, newdata=NULL,
               type=c("surv","cumhaz","hazard","density","hr","sdiff",
               "hdiff","loghazard","link","meansurv","meansurvdiff","meanhr",
               "odds","or","margsurv","marghaz","marghr","meanhaz","af",
               "fail","margfail","meanmargsurv","uncured","rmst","probcure",
               "lpmatrix", "gradh", "gradH","rmstdiff"),
               grid=FALSE,seqLength=300,
               type.relsurv=c("excess","total","other"), scale=365.24,
               rmap, ratetable=survival::survexp.us,
               se.fit=FALSE,link=NULL,exposed=NULL,var=NULL,
               keep.attributes=FALSE, use.gr=TRUE,level=0.95,
               n.gauss.quad=100,full=FALSE,...)
    ## S4 method for signature 'pstpm2'
predict(object, newdata=NULL,
               type=c("surv","cumhaz","hazard","density","hr","sdiff",
               "hdiff","loghazard","link","meansurv","meansurvdiff","meanhr",
               "odds","or","margsurv","marghaz","marghr","meanhaz","af",
               "fail","margfail","meanmargsurv","rmst","lpmatrix",
               "gradh", "gradH","rmstdiff"),
               grid=FALSE,seqLength=300,
               se.fit=FALSE,link=NULL,exposed=NULL,var=NULL,
               keep.attributes=FALSE, use.gr=TRUE,level=0.95,
               n.gauss.quad=100,full=FALSE,...)

Arguments

object

an stpm2 or pstpm2 object

newdata

optional list of new data (required if type in ("hr","sdiff","hdiff","meansurvdiff","or","uncured")). For type in ("hr","sdiff","hdiff","meansurvdiff","or","af","uncured"), 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).

type

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

  • "meanhr"mean hazard ratio

  • "af"attributable fraction

  • "fail"failure (=1-survival)

  • "margfail"marginal failure (=1-marginal survival)

  • "meanmargsurv"mean marginal survival, averaged over the frailty distribution

  • "uncured"distribution for the uncured

  • "rmst"restricted mean survival time

  • "rmstdiff"restricted mean survival time difference

  • "probcure"probability of cure

  • "lpmatrix"design matrix

grid

whether to merge newdata with a regular sequence of event times (default=FALSE)

seqLength

length of the sequence used when grid=TRUE

type.relsurv

type of predictions for relative survival models: either "excess", "total" or "other"

scale

scale to go from the days in the ratetable object to the analysis time used in the analysis

rmap

an optional list that maps data set names to the ratetable names. See survexp

ratetable

a table of event rates used in relative survival when type.relsurv is "total" or "other"

se.fit

whether to calculate confidence intervals (default=FALSE)

link

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"))

exposed

a function that takes newdata and returns a transformed data-frame for those exposed or the counterfactual. By default, this increments var (except for cure models, where it defaults to the last event time).

var

specify the variable name or names for the exposed/unexposed (names are given as characters)

keep.attributes

Boolean to determine whether the output should include the newdata as an attribute (default=TRUE)

use.gr

Boolean to determine whether to use gradients in the variance calculations when they are available (default=TRUE)

level

confidence level for the confidence intervals (default=0.95)

n.gauss.quad

number of Gauassian quadrature points used for integrations (default=100)

full

logical for whether to return a full data-frame with predictions and newdata combined. Useful for lattice and ggplot2 plots. (default=FALSE)

...

additional arguments (for generic compatibility)

Details

The confidence interval estimation is based on the delta method using numerical differentiation.

Value

A data-frame with components Estimate, lower and upper, with an attribute "newdata" for the newdata data-frame.

Methods

object= "stpm2"

an stpm2 fit

See Also

stpm2


rstpm2 documentation built on March 31, 2023, 8:22 p.m.