Description Usage Arguments Details Value Author(s) References See Also Examples
Flexible parametric modelling of time-to-event data using the spline model of Royston and Parmar (2002).
1 2 |
formula |
A formula expression in conventional R linear modelling
syntax. The response must be a survival object as returned by the
If there are no covariates, specify |
data |
A data frame in which to find variables supplied in |
k |
Number of knots in the spline. The default |
knots |
Locations of knots on the axis of log time. If not specified, knot
locations are chosen as described in |
scale |
If If If |
weights |
Optional vector of case weights. |
subset |
Vector of integer or logicals specifying the subset of the observations to be used in the fit. |
na.action |
a missing-data filter function, applied after any 'subset' argument has been used. Default is 'options()$na.action'. |
inits |
A numeric vector giving initial values for each unknown parameter. If not specified, default initial values are chosen by estimating the baseline survival at each observed death time from the equivalent Cox model, transforming to the log cumulative hazard log(H) (or equivalent under the odds or normal models) then performing a linear regression of log(H) on the spline basis and covariates. |
fixedpars |
Vector of indices of parameters whose values will be
fixed at their initial values during optimisation. The indices
are ordered with the intercept |
cl |
Width of symmetric confidence intervals for maximum likelihood estimates, by default 0.95. |
... |
Optional arguments to the general-purpose R
optimisation routine |
In the spline-based survival model of Royston and Parmar (2002), a transformation g(S(t,z)) of the survival function is modelled as a natural cubic spline function of log time x = log(t) plus linear effects of covariates z.
g(S(t,z)) = s(x, gamma) + beta^T z
The proportional hazards model (scale="hazard"
) defines
g(S(t,z)) =
log(-log(S(t,z))) = log(H(t,z)), the log
cumulative hazard.
The proportional odds model (scale="odds"
) defines g(S(t,z)) = log(1/S(t,z) - 1), the log
cumulative odds.
The probit model (scale="normal"
) defines g(S(t,z)) = -InvPhi(S(t,z)),
where InvPhi() is the
inverse normal distribution function qnorm
.
With no knots, the spline reduces to a linear function, and these models are equivalent to Weibull, log-logistic and lognormal models respectively.
Natural cubic splines are cubic splines constrained to be linear beyond boundary knots kmin,kmax. The spline function is defined as
s(x,gamma) = gamma0 + gamma1 x + gamma2 v1(x) + ... + gamma_{m+1} vm(x)
where vj(x) is the jth basis function
vj(x) = (x - kj)^3_+ - λ_j(x - kmin)^3_+ - (1 -λ_j) (x - kmax)^3_+
λ_j = (kmax - kj) / (kmax - kmin)
and (x - a)_+ = max(0, x - a).
Parameters gamma,beta are estimated by maximum likelihood
using the algorithms available in the standard R
optim
function. Confidence intervals are estimated from
the Hessian at the maximum.
A list of class "flexsurvreg"
with the following elements.
call |
A copy of the function call, for use in post-processing. |
k |
Number of knots. |
knots |
Location of knots on the log time axis. |
res |
Matrix of maximum likelihood estimates and confidence
limits. Spline coefficients are labelled Coefficients In the Weibull model, for example, In the log-logistic model with shape In the log-normal model with log-scale mean |
loglik |
The maximised log-likelihood. This will differ from Stata, where the sum of the log uncensored survival times is added to the log-likelihood in survival models, to remove dependency on the time scale. |
AIC |
Akaike's information criterion (-2*log likelihood + 2*number of estimated parameters) |
Christopher Jackson <chris.jackson@mrc-bsu.cam.ac.uk>
Royston, P. and Parmar, M. (2002). Flexible parametric proportional-hazards and proportional-odds models for censored survival data, with application to prognostic modelling and estimation of treatment effects. Statistics in Medicine 21(1):2175-2197.
flexsurvreg
for flexible survival modelling using
fully parametric distributions including the generalized F and gamma.
plot.flexsurvreg
and lines.flexsurvreg
to
plot fitted survival, hazards and cumulative hazards from models fitted
by flexsurvspline
and flexsurvreg
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | data(bc)
bc$recyrs <- bc$rectime/365
## Best-fitting model to breast cancer data from Royston and Parmar (2002)
## One internal knot (2 df) and cumulative odds scale
spl <- flexsurvspline(Surv(recyrs, censrec) ~ group, data=bc, k=1, scale="odds")
## Fitted survival
plot(spl, ci=TRUE, lwd=3, lwd.ci=1, col.ci="gray")
## Simple Weibull model fits much less well
splw <- flexsurvspline(Surv(recyrs, censrec) ~ group, data=bc, k=0, scale="hazard")
lines(splw, col="blue")
## Alternative way of fitting the Weibull
splw2 <- flexsurvreg(Surv(recyrs, censrec) ~ group, data=bc, dist="weibull")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.