Package 'rmstBayespara'

Title: Bayesian Restricted Mean Survival Time for Cluster Effect
Description: The parametric Bayes analysis for the restricted mean survival time (RMST) with cluster effect, as described in Hanada and Kojima (2024) <doi:10.48550/arXiv.2406.06071>. Bayes estimation with random-effect and frailty-effect can be applied to several parametric models useful in survival time analysis. The RMST under these parametric models can be computed from the obtained posterior samples.
Authors: Keisuke Hanada [aut, cre] , Masahiro Kojima [aut]
Maintainer: Keisuke Hanada <[email protected]>
License: GPL (>= 3)
Version: 0.1.0
Built: 2025-03-01 04:22:05 UTC
Source: https://github.com/keisuke-hanada/rmstbayespara

Help Index


The 'rmstBayespara' package.

Description

The parametric Bayes regression models using 'Stan' for restricted mean survival time (RMST). The package implement the model estimation described in Hanada and Kojima (2024). The posterior sample, Widely Applicable Information Criterion (WAIC), and Efficient Leave-One-Out Cross-Validation (loo) for some parametric models of survival data can be available. The RMST under these parametric models can be computed from the obtained posterior samples.

Author(s)

Maintainer: Keisuke Hanada [email protected] (ORCID)

Authors:

  • Masahiro Kojima (ORCID)

References

Hanada, K., & Kojima, M. (2024). Bayesian Parametric Methods for Deriving Distribution of Restricted Mean Survival Time. arXiv e-prints, arXiv-2406.


Bayesian regression models using 'Stan' for survival time

Description

A function of Bayesian regression models using stan for parametric survival time. Exponential, Weibull, log-normal, and log-logistic model with fixed-effect, random-effect and frailty-effect can be available.

Usage

brm_surv(
  time,
  cnsr,
  var,
  rvar,
  family = "exponential",
  random = "fixed",
  data,
  iter = 2000,
  warmup = 1000,
  seed = NA,
  chains = 4
)

Arguments

time

name of time variable in data. Need to set character.

cnsr

name of censor variable in data. Need to set character.

var

vector of covariate names in data. Need to set character.

rvar

name of random effect in data. Need to set character.

family

A description of the response distribution and link function to be used in the model. 'exponential', 'Weibull', 'log-normal', and 'log-logistic' can be selected.

random

A description of random effect. 'fixed', 'normal', and 'frailty' are available.

data

An object of class data.frame (or one that can be coerced to that class) containing data of all variables used in the model.

iter

Number of total iterations per chain (including warmup; defaults to 2000).

warmup

A positive integer specifying number of warmup (aka burnin) iterations. This also specifies the number of iterations used for stepsize adaptation, so warmup draws should not be used for inference. The number of warmup should not be larger than iter and the default is iter/2.

seed

The seed for random number generation to make results reproducible. If NA (the default), Stan will set the seed randomly.

chains

Number of Markov chains (defaults to 4).

Value

A list of an object of class brmsfit or stanfit (see rstan and brms), sampling values from posterior distribution, leave-one-out cross-validation, and widely applicable information criterions.

Examples

d <- data.frame(time=1:100,
      status=sample(0:1, size=100, replace=TRUE),
      arm=sample(c("t", "c"), size=100, replace=TRUE),
      sex=sample(1:2, size=100, replace=TRUE),
      district=sample(1:5, size=100, replace=TRUE)
    )
head(d)
fit_x_r <- brm_surv(time="time", cnsr="1-status",
                    var=c("factor(arm)", "factor(sex)"),
                    rvar="district", data=d,
                    family="Weibull", random="frailty"
                    )
fit_x_r$fit
fit_x_r$post_sample
fit_x_r$waic
fit_x_r$loo

Restricted mean survival time via parametric models

Description

A function of calculating restricted mean survival time via parametric models. Exponential, Weibull, log-normal and log-logistic models are available.

Usage

rmstpara(
  tau,
  var,
  rvar = NA,
  shape = NA,
  sigma = NA,
  family = "exponential",
  random = "fixed"
)

Arguments

tau

A value of pre-specified evaluation time point.

var

A vector of covariate values.

rvar

a vector of frailty effects. It is necessary when log-normal frailty and log-logistic frailty models.

shape

a vector of shape parameters. It is necessary when Weibull and log-logistic models.

sigma

a vector of standard error parameters. It is necessary when log-normal model.

family

A description of the response distribution and link function to be used in the model. 'exponential', 'Weibull', 'log-normal', and 'log-logistic' can be selected.

random

A description of random effect. 'fixed', 'normal', and 'frailty' are available.

Value

An object of class brmsfit or stanfit. See rstan and brms.

Examples

d <- data.frame(time=1:100,
      status=sample(0:1, size=100, replace=TRUE),
      arm=sample(c("t", "c"), size=100, replace=TRUE),
      sex=sample(1:2, size=100, replace=TRUE),
      district=sample(1:5, size=100, replace=TRUE)
    )
head(d)
fit_x_r <- brm_surv(time="time", cnsr="1-status",
                    var=c("factor(arm)", "factor(sex)"),
                    rvar="district", data=d,
                    family="Weibull", random="frailty")
fit_x_r$post_sample
ps_x_r<-fit_x_r$post_sample
rmst_x_r<-rmstpara(tau=100, var=ps_x_r[,"b_intercept"]+ps_x_r[,"b_factor(arm)"],
                   shape=ps_x_r[,"shape"], rvar=ps_x_r[,"sd_district"],
                   family="Weibull",random="frailty")
rmst_x_r