Description Usage Arguments Details Examples
Bayesian inference for multi-state models (sometimes known as models for
competing risk data). Currently, the command fits standard parametric
(exponential, Weibull and Gompertz) and flexible parametric (cubic
spline-based) hazard models on the hazard scale, with covariates included
under assumptions of either proportional or non-proportional hazards.
Where relevant, non-proportional hazards are modelled using a flexible
cubic spline-based function for the time-dependent effect (i.e. the
time-dependent hazard ratio).
1 2 3 4 5 6 7 8 9 10 11 | idmstan(formula01, formula02, formula12, data, h = 3, basehaz01 = "ms",
basehaz02 = "ms", basehaz12 = "ms", basehaz_ops01, basehaz_ops02,
basehaz_ops12, prior01 = rstanarm::normal(),
prior_intercept01 = rstanarm::normal(),
prior_aux01 = rstanarm::normal(), prior02 = rstanarm::normal(),
prior_intercept02 = rstanarm::normal(),
prior_aux02 = rstanarm::normal(), prior12 = rstanarm::normal(),
prior_intercept12 = rstanarm::normal(),
prior_aux12 = rstanarm::normal(), prior_PD = FALSE,
algorithm = c("sampling", "meanfield", "fullrank"),
adapt_delta = 0.95, ...)
|
data |
A data frame containing the variables specified in
|
formula |
A two-sided formula object describing the model.
The left hand side of the formula should be a |
basehaz |
A character string indicating which baseline hazard to use for the event submodel. Current options are:
|
basehaz_ops |
A named list specifying options related to the baseline
hazard. Currently this can include:
Note that for the M-splines and B-splines - in addition to any internal
|
qnodes |
The number of nodes to use for the Gauss-Kronrod quadrature
that is used to evaluate the cumulative hazard when |
prior_intercept |
The prior distribution for the intercept. Note
that there will only be an intercept parameter when Where relevant, |
prior_aux |
The prior distribution for "auxiliary" parameters related to
the baseline hazard. The relevant parameters differ depending
on the type of baseline hazard specified in the
Currently, |
prior_smooth |
This is only relevant when time-dependent effects are
specified in the model (i.e. the |
By default, any covariate effects specified in the formula
are
included in the model under a proportional hazards assumption. To relax
this assumption, it is possible to estimate a time-dependent coefficient
for a given covariate. This can be specified in the model formula
by wrapping the covariate name in the tde()
function (note that
this function is not an exported function, rather it is an internal function
that can only be evaluated within the formula of a stan_surv
call).
For example, if we wish to estimate a time-dependent effect for the
covariate sex
then we can specify tde(sex)
in the
formula
, e.g. Surv(time, status) ~ tde(sex) + age + trt
.
The coefficient for sex
will then be modelled
using a flexible smooth function based on a cubic B-spline expansion of
time.
The flexibility of the smooth function can be controlled in two ways:
First, through control of the prior distribution for the cubic B-spline
coefficients that are used to model the time-dependent coefficient.
Specifically, one can control the flexibility of the prior through
the hyperparameter (standard deviation) of the random walk prior used
for the B-spline coefficients; see the prior_smooth
argument.
Second, one can increase or decrease the number of degrees of
freedom used for the cubic B-spline function that is used to model the
time-dependent coefficient. By default the cubic B-spline basis is
evaluated using 3 degrees of freedom (that is a cubic spline basis with
boundary knots at the limits of the time range, but no internal knots).
If you wish to increase the flexibility of the smooth function by using a
greater number of degrees of freedom, then you can specify this as part
of the tde
function call in the model formula. For example, to
use cubic B-splines with 7 degrees of freedom we could specify
tde(sex, df = 7)
in the model formula instead of just
tde(sex)
. See the Examples section below for more
details.
In practice, the default tde()
function should provide sufficient
flexibility for model most time-dependent effects. However, it is worth
noting that the reliable estimation of a time-dependent effect usually
requires a relatively large number of events in the data (e.g. >1000).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #---------- Proportional hazards
# Simulated data
library("SemiCompRisks")
library("scales")
# Data generation parameters
n <- 1500
beta1.true <- c(0.1, 0.1)
beta2.true <- c(0.2, 0.2)
beta3.true <- c(0.3, 0.3)
alpha1.true <- 0.12
alpha2.true <- 0.23
alpha3.true <- 0.34
kappa1.true <- 0.33
kappa2.true <- 0.11
kappa3.true <- 0.22
theta.true <- 0
# Make design matrix with single binary covariate
x_c <- rbinom(n, size = 1, prob = 0.7)
x_m <- cbind(1, x_c)
# Generate semicompeting data
dat_ID <- SemiCompRisks::simID(x1 = x_m, x2 = x_m, x3 = x_m,
beta1.true = beta1.true,
beta2.true = beta2.true,
beta3.true = beta3.true,
alpha1.true = alpha1.true,
alpha2.true = alpha2.true,
alpha3.true = alpha3.true,
kappa1.true = kappa1.true,
kappa2.true = kappa2.true,
kappa3.true = kappa3.true,
theta.true = theta.true,
cens = c(240, 360))
dat_ID$x_c <- x_c
colnames(dat_ID)[1:4] <- c("R", "delta_R", "tt", "delta_T")
formula01 <- Surv(time=rr,event=delta_R)~x_c
formula02 <- Surv(time=tt,event=delta_T)~x_c
formula12 <- Surv(time=difft,event=delta_T)~x_c
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.