Prediction function for an exposure-response TTE model
Arguments
- object
An ertte model, as returned by
ertte_model()
Value
A function with arguments param, data, and time.
The
paramargument should be a vector of location coefficients; defaults tocoef(object)(the fitted coefficients) if not supplied.The
dataargument should be a data frame or tibble; defaults toobject$data(the data the model was fitted to) if not supplied.The
timeargument gives the time(s) at which to evaluate the survival function; recycled againstdata.
Details
Takes a fitted ertte model as input and returns a function
that evaluates the survival function S(t) at user-specified
parameters, data, and times (e.g. for VPCs or other counterfactual
simulation scenarios). Named ertte_fun() for consistency with the
companion erglm/emaxnls packages' erglm_fun()/emax_fun(),
which serve the same purpose for their respective model classes. The
returned function checks that param is numeric and has one entry
per column of the model matrix implied by data, erroring
informatively rather than failing with a cryptic "non-conformable
arguments" error from matrix multiplication. scale is always taken
from the fitted object, not from param (the coefficient vector
from coef() never includes it).
Examples
mod <- ertte_model(survival::Surv(time, event) ~ aucss, ertte_data)
mod_fun <- ertte_fun(mod)
# no arguments: reproduces the fitted model's own survival predictions
s1 <- mod_fun(time = 60)
# user modifies the parameters
par2 <- coef(mod)
par2["(Intercept)"] <- par2["(Intercept)"] + 1
s2 <- mod_fun(param = par2, time = 60)