dsurvspline(x, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0, log=FALSE)
psurvspline(q, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0, lower.tail=TRUE, log.p=FALSE)
qsurvspline(p, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0, lower.tail=TRUE, log.p=FALSE)
rsurvspline(n, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0)
hsurvspline(x, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0)
Hsurvspline(x, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", timescale="log", offset=0)
flexsurvspline
.
This may be supplied as a vector with number of elements
equal to the length of knots
, in which case the parameters
are common to all times. Alternatively a matrix may be supplied,
with rows corresponding to different times, and columns
corresponding to knots
.
flexsurvspline
, these
include the two boundary knots. If there are
no additional knots, the boundary locations are not used. If there
are one or more additional knots, the boundary knots should be at
or beyond the minimum and maximum values of the log times.
In flexsurvspline
these are exactly at the minimum
and maximum values. This may in principle be supplied as a matrix, in the same way as
for gamma
, but in most applications the knots will be fixed.
"hazard"
, "odds"
, or "normal"
, as
described in flexsurvspline
. With the default of
no knots in addition to the boundaries, this model reduces to the
Weibull, log-logistic and log-normal respectively. The scale must be
common to all times. "log"
or "identity"
as described in flexsurvspline
.dsurvspline
gives the density, psurvspline
gives the distribution
function, hsurvspline
gives the hazard and Hsurvspline
gives the cumulative hazard, as described in flexsurvspline
.qsurvspline
gives the quantile function, which is computed by crude
numerical inversion (using qgeneric
).rsurvspline
generates random survival times by using
qsurvspline
on a sample of uniform random numbers. Due to the
numerical root-finding involved in qsurvspline
, it is slow compared to typical random number generation functions.
flexsurvspline
.
## reduces to the weibull
regscale <- 0.786; cf <- 1.82
a <- 1/regscale; b <- exp(cf)
dweibull(1, shape=a, scale=b)
dsurvspline(1, gamma=c(log(1 / b^a), a)) # should be the same
## reduces to the log-normal
meanlog <- 1.52; sdlog <- 1.11
dlnorm(1, meanlog, sdlog)
dsurvspline(1, gamma = c(-meanlog/sdlog, 1/sdlog), scale="normal")
# should be the same
Run the code above in your browser using DataLab