rmstpara {rmstBayespara}R Documentation

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



[Package rmstBayespara version 0.1.0 Index]