mspline_spec {survextrap} | R Documentation |
Make default M-spline knot specification given a survival dataset.
Description
Choose default M-spline knot locations given a dataset and desired number of spline parameters. Assumes a cubic spline, and knots based on quantiles of event times observed in the individual data.
Usage
mspline_spec(
formula,
data,
cure = FALSE,
nonprop = NULL,
backhaz = NULL,
backhaz_strata = NULL,
external = NULL,
df = 10,
add_knots = NULL,
degree = 3,
bsmooth = TRUE
)
Arguments
formula |
A survival formula in standard R formula syntax, with a call to Covariates included on the right hand side of the formula with be
modelled with proportional hazards, or if If |
data |
Data frame containing variables in This may be omitted, in which case |
cure |
If |
nonprop |
Non-proportional hazards model specification. This is achieved by modelling the spline basis coefficients in terms of the covariates. See the methods vignette for more details. If If this is a formula, then this is assumed to define a model for the dependence of the basis coefficients on the covariates. IF this is |
backhaz |
Background hazard, that is, for causes of death
other than the cause of interest. This defines a
"relative survival" or "additive hazards" model. The overall
hazard that describes the all-cause survival data (given in the
The background hazard is assumed to be known, and the cause-specific hazard is modelled with the flexible parametric model. The background hazard can be supplied in two forms. The meaning of predictions from the model depends on which of these is used. (a) A data frame with columns (b) The (quoted) name of a variable in the data giving the
background hazard. For censored cases, the exact value does not
matter. The predictions from If there is external data, and If there are stratifying variables specified in
If |
backhaz_strata |
A character vector of names of variables that
appear in This is If stratification is done, then |
external |
External data as a data frame of aggregate survival counts with columns named:
If there are covariates in |
df |
Desired number of basis terms, or "degrees of freedom"
in the spline. If |
add_knots |
Additional knots, other than those determined from the quantiles of the individual data. Typically used to add a maximum knot at the time that we want to extrapolate to. |
degree |
Spline polynomial degree. Can only be changed from
the default of 3 if |
bsmooth |
If |
Details
If there are also external data, then these are based on quantiles of a vector defined by concatenating the event times in the individual data with the unique start and stop times in the external data.
This is designed to have the same arguments as
survextrap
. It is intended for use when we want to
fit a set of survextrap
models with the same spline
specification.
See also mspline_list_init
and mspline_init
,
which have lower-level interfaces, and are designed for use without
data, e.g. when illustrating a theoretical M-spline model.
Value
A list with components
knots
Knot locations. The number of
knots will be equal to df
+ degree
+ 2.
degree
Spline polynomial degree (i.e. 3)
nvars
Number of basis variables (an alias for df
)