Skip to contents

yppe: Fit the Yang and Prentice Regression Model with Piecewise Exponential baseline distribution.

Usage

yppe(
  formula,
  data,
  n_int = NULL,
  rho = NULL,
  tau = NULL,
  hessian = TRUE,
  approach = c("mle", "bayes"),
  hyper_parms = list(h1_gamma = 0, h2_gamma = 4, mu_psi = 0, sigma_psi = 4, mu_phi = 0,
    sigma_phi = 4, mu_beta = 0, sigma_beta = 4),
  ...
)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which yppe is called.

n_int

number of intervals of the PE distribution. If NULL, default value (square root of n) is used.

rho

the time grid of the PE distribution. If NULL, the function timeGrid is used to compute rho.

tau

the maximum time of follow-up. If NULL, tau = max(time), where time is the vector of observed survival times.

hessian

logical; If TRUE (default), the hessian matrix is returned when approach="mle".

approach

approach to be used to fit the model (mle: maximum likelihood; bayes: Bayesian approach).

hyper_parms

a list containing the hyper-parameters of the prior distributions (when approach = "bayes"). If not specified, default values are used.

...

Arguments passed to either `rstan::optimizing` or `rstan::sampling` .

Value

yppe returns an object of class "yppe" containing the fitted model.

Examples

# \donttest{
# ML approach:
library(YPPE)
mle <- yppe(Surv(time, status)~arm, data=ipass, n_int=10, approach="mle")
summary(mle)
#> Call:
#> yppe(formula = Surv(time, status) ~ arm, data = ipass, n_int = 10, 
#>     approach = "mle")
#> 
#> Short-term coefficients:
#>     Estimate  StdErr z.value   p.value    
#> arm  1.04170 0.16656  6.2541 3.997e-10 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Long-term coefficients:
#>      Estimate    StdErr z.value   p.value    
#> arm -1.238516  0.084555 -14.648 < 2.2e-16 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> --- 
#> loglik = -2759.652   AIC = 5543.305 

# Bayesian approach:
bayes <- yppe(Surv(time, status)~arm, data=ipass, n_int=10, approach="bayes")
#> 
#> SAMPLING FOR MODEL 'yppe' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.000726 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.26 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 1: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 1: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 1: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 1: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 6.721 seconds (Warm-up)
#> Chain 1:                5.941 seconds (Sampling)
#> Chain 1:                12.662 seconds (Total)
#> Chain 1: 
#> 
#> SAMPLING FOR MODEL 'yppe' NOW (CHAIN 2).
#> Chain 2: 
#> Chain 2: Gradient evaluation took 0.000703 seconds
#> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 7.03 seconds.
#> Chain 2: Adjust your expectations accordingly!
#> Chain 2: 
#> Chain 2: 
#> Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 2: 
#> Chain 2:  Elapsed Time: 6.36 seconds (Warm-up)
#> Chain 2:                5.728 seconds (Sampling)
#> Chain 2:                12.088 seconds (Total)
#> Chain 2: 
#> 
#> SAMPLING FOR MODEL 'yppe' NOW (CHAIN 3).
#> Chain 3: 
#> Chain 3: Gradient evaluation took 0.000712 seconds
#> Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 7.12 seconds.
#> Chain 3: Adjust your expectations accordingly!
#> Chain 3: 
#> Chain 3: 
#> Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 3: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 3: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 3: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 3: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 3: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 3: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 3: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 3: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 3: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 3: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 3: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 3: 
#> Chain 3:  Elapsed Time: 6.71 seconds (Warm-up)
#> Chain 3:                5.97 seconds (Sampling)
#> Chain 3:                12.68 seconds (Total)
#> Chain 3: 
#> 
#> SAMPLING FOR MODEL 'yppe' NOW (CHAIN 4).
#> Chain 4: 
#> Chain 4: Gradient evaluation took 0.000732 seconds
#> Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 7.32 seconds.
#> Chain 4: Adjust your expectations accordingly!
#> Chain 4: 
#> Chain 4: 
#> Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
#> Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
#> Chain 4: Iteration:  400 / 2000 [ 20%]  (Warmup)
#> Chain 4: Iteration:  600 / 2000 [ 30%]  (Warmup)
#> Chain 4: Iteration:  800 / 2000 [ 40%]  (Warmup)
#> Chain 4: Iteration: 1000 / 2000 [ 50%]  (Warmup)
#> Chain 4: Iteration: 1001 / 2000 [ 50%]  (Sampling)
#> Chain 4: Iteration: 1200 / 2000 [ 60%]  (Sampling)
#> Chain 4: Iteration: 1400 / 2000 [ 70%]  (Sampling)
#> Chain 4: Iteration: 1600 / 2000 [ 80%]  (Sampling)
#> Chain 4: Iteration: 1800 / 2000 [ 90%]  (Sampling)
#> Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
#> Chain 4: 
#> Chain 4:  Elapsed Time: 6.908 seconds (Warm-up)
#> Chain 4:                6.151 seconds (Sampling)
#> Chain 4:                13.059 seconds (Total)
#> Chain 4: 
summary(bayes)
#> Call:
#> yppe(formula = Surv(time, status) ~ arm, data = ipass, n_int = 10, 
#>     approach = "bayes")
#> 
#> Short-term coefficients:
#>      mean se_mean    sd  2.5%   25%   50%   75% 97.5%    n_eff Rhat
#> arm 1.039   0.003 0.166 0.722 0.926 1.036 1.151 1.373 2734.998    1
#> 
#> Long-term coefficients:
#>       mean se_mean    sd 2.5%   25%    50%    75%  97.5%    n_eff Rhat
#> arm -1.234   0.002 0.084 -1.4 -1.29 -1.233 -1.178 -1.071 2967.796    1
#> 
#> --- 
#> Inference for Stan model: yppe.
#> 4 chains, each with iter=2000; warmup=1000; thin=1; 
#> post-warmup draws per chain=1000, total post-warmup draws=4000.
#> 
# }