Title: | Yang and Prentice Model with Baseline Distribution Modeled by Bernstein Polynomials |
---|---|
Description: | Semiparametric modeling of lifetime data with crossing survival curves via Yang and Prentice model with baseline hazard/odds modeled with Bernstein polynomials. Details about the model can be found in Demarqui et al. (2019) <arXiv:1910.04475>. Model fitting can be carried out via both maximum likelihood and Bayesian approaches. The package also provides point and interval estimation for the crossing survival times. |
Authors: | Fabio Demarqui [aut, cre] |
Maintainer: | Fabio Demarqui <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.1 |
Built: | 2025-01-24 04:27:53 UTC |
Source: | https://github.com/fndemarqui/ypbp |
Semiparametric modeling of lifetime data with crossing survival curves via Yang and Prentice model with baseline hazard/odds modeled with Bernstein polynomials. Details about the model can be found in Demarqui and Mayrink (2019) <arXiv:1910.04475>. Model fitting can be carried out via maximum likelihood or Bayesian approaches. The package also provides point and interval estimation for the crossing survival times.
Demarqui, F. N. and Mayrink, V. D. (2019). An Unified Semiparametric Approach to Model Lifetime Data with Crossing Survival Curves. <arXiv:1910.04475>
Yang, S. and Prentice, R. L. (2005). Semiparametric analysis of short-term and long-term hazard ratios with two-sample survival data. Biometrika 92, 1-17.
Stan Development Team (2019). RStan: the R interface to Stan. R package version 2.19.2. https://mc-stan.org
This function returns the estimated regression coefficients when the maximum likelihood estimation approach is used in the model fitting.
## S3 method for class 'ypbp' coef(object, ...)
## S3 method for class 'ypbp' coef(object, ...)
object |
an object of the class ypbp. |
... |
further arguments passed to or from other methods. |
the estimated regression coefficients.
fit <- ypbp(Surv(time, status)~arm, data=ipass) coef(fit)
fit <- ypbp(Surv(time, status)~arm, data=ipass) coef(fit)
Generic S3 method confint
confint(object, ...)
confint(object, ...)
object |
a fitted model object |
... |
further arguments passed to or from other methods. |
the confidence intervals for the regression coefficients
This function returns the estimated confidence intervals for the regression coefficients when the maximum likelihood estimation approach is used in the model fitting.
## S3 method for class 'ypbp' confint(object, level = 0.95, ...)
## S3 method for class 'ypbp' confint(object, level = 0.95, ...)
object |
an object of the class ypbp. |
level |
the confidence level required. |
... |
further arguments passed to or from other methods. |
A matrix (or vector) with columns giving lower and upper confidence limits for the regression coefficients. These will be labeled as (1-level)/2 and 1 - (1-level)/2 in % (by default 2.5% and 97.5%).
fit <- ypbp(Surv(time, status)~arm, data=ipass) confint(fit)
fit <- ypbp(Surv(time, status)~arm, data=ipass) confint(fit)
Generic S3 method crossTime
crossTime(object, ...)
crossTime(object, ...)
object |
a fitted model object |
... |
further arguments passed to or from other methods. |
the crossing survival time
Computes the crossing survival times along with their corresponding confidence/credible intervals.
## S3 method for class 'ypbp' crossTime(object, newdata1, newdata2, conf.level = 0.95, nboot = 4000, ...)
## S3 method for class 'ypbp' crossTime(object, newdata1, newdata2, conf.level = 0.95, nboot = 4000, ...)
object |
an object of class ypbp |
newdata1 |
a data frame containing the first set of explanatory variables |
newdata2 |
a data frame containing the second set of explanatory variables |
conf.level |
level of the confidence/credible intervals; default is conf.level = 0.95 |
nboot |
number of bootstrap samples (default nboot=4000); ignored if approach="bayes". |
... |
further arguments passed to or from other methods. |
the crossing survival time
# ML approach: library(YPBP) mle <- ypbp(Surv(time, status)~arm, data=ipass, approach="mle") summary(mle) newdata1 <- data.frame(arm=0) newdata2 <- data.frame(arm=1) tcross <- crossTime(mle, newdata1, newdata2, nboot = 100) tcross ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(mle, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) abline(v=tcross, col="blue") # Bayesian approach: bayes<-ypbp(Surv(time,status)~arm,data=ipass,approach="bayes",chains=2,iter=100) summary(bayes) newdata1 <- data.frame(arm=0) newdata2 <- data.frame(arm=1) tcross <- crossTime(bayes, newdata1, newdata2) tcross ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(bayes, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) abline(v=tcross, col="blue")
# ML approach: library(YPBP) mle <- ypbp(Surv(time, status)~arm, data=ipass, approach="mle") summary(mle) newdata1 <- data.frame(arm=0) newdata2 <- data.frame(arm=1) tcross <- crossTime(mle, newdata1, newdata2, nboot = 100) tcross ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(mle, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) abline(v=tcross, col="blue") # Bayesian approach: bayes<-ypbp(Surv(time,status)~arm,data=ipass,approach="bayes",chains=2,iter=100) summary(bayes) newdata1 <- data.frame(arm=0) newdata2 <- data.frame(arm=1) tcross <- crossTime(bayes, newdata1, newdata2) tcross ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(bayes, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) abline(v=tcross, col="blue")
Data set from a clinical trial conducted by the Gastrointestinal Tumor Study Group (GTSG) in 1982. The data set refers to the survival times of patients with locally nonresectable gastric cancer. Patients were either treated with chemotherapy combined with radiation or chemotherapy alone.
A data frame with 90 rows and 3 variables:
time: survival times (in days)
status: failure indicator (1 - failure; 0 - otherwise)
trt: treatments (1 - chemotherapy + radiation; 0 - chemotherapy alone)
Gastrointestinal Tumor Study Group. (1982) A Comparison of Combination Chemotherapy and Combined Modality Therapy for Locally Advanced Gastric Carcinoma. Cancer 49:1771-7.
Reconstructed IPASS clinical trial data reported in Argyropoulos and Unruh (2015). Although reconstructed, this data set preserves all features exhibited in references with full access to the observations from this clinical trial. The data base is related to the period of March 2006 to April 2008. The main purpose of the study is to compare the drug gefitinib against carboplatin/paclitaxel doublet chemotherapy as first line treatment, in terms of progression free survival (in months), to be applied to selected non-small-cell lung cancer (NSCLC) patients.
A data frame with 1217 rows and 3 variables:
time: progression free survival (in months)
status: failure indicator (1 - failure; 0 - otherwise)
arm: (1 - gefitinib; 0 - carboplatin/paclitaxel doublet chemotherapy)
Argyropoulos, C. and Unruh, M. L. (2015). Analysis of time to event outcomes in randomized controlled trials by generalized additive models. PLOS One 10, 1-33.
Reconstruct the model matrix (or matrices if the alternative formulation of the YP model is used) for a ypbp model.
## S3 method for class 'ypbp' model.matrix(object, ...)
## S3 method for class 'ypbp' model.matrix(object, ...)
object |
an object of the class ypbp. |
... |
further arguments passed to or from other methods. |
The model matrix (or matrices) for the fit.
fit <- ypbp(Surv(time, status)~arm, data=ipass) model.matrix(fit)
fit <- ypbp(Surv(time, status)~arm, data=ipass) model.matrix(fit)
Print the summary.ypbp output
## S3 method for class 'summary.ypbp' print(x, ...)
## S3 method for class 'summary.ypbp' print(x, ...)
x |
an object of the class summary.ypbp. |
... |
further arguments passed to or from other methods. |
a summary of the fitted model.
Summary for the ypbp model
## S3 method for class 'ypbp' summary(object, ...)
## S3 method for class 'ypbp' summary(object, ...)
object |
an objecto of the class 'ypbp'. |
... |
further arguments passed to or from other methods. |
Computes the predicted survivor function for a ypbp model.
## S3 method for class 'ypbp' survfit(formula, newdata, ...)
## S3 method for class 'ypbp' survfit(formula, newdata, ...)
formula |
an object of the class ypbp |
newdata |
a data frame containing the set of explanatory variables. |
... |
further arguments passed to or from other methods. |
a list containing the estimated survival probabilities.
# ML approach: library(YPBP) mle <- ypbp(Surv(time, status)~arm, data=ipass, approach="mle") summary(mle) ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(mle, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) # Bayesian approach: bayes <- ypbp(Surv(time, status) ~ arm, data = ipass, approach = "bayes", chains = 2, iter = 100) summary(bayes) ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(bayes, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2))
# ML approach: library(YPBP) mle <- ypbp(Surv(time, status)~arm, data=ipass, approach="mle") summary(mle) ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(mle, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2)) # Bayesian approach: bayes <- ypbp(Surv(time, status) ~ arm, data = ipass, approach = "bayes", chains = 2, iter = 100) summary(bayes) ekm <- survival::survfit(Surv(time, status)~arm, data=ipass) newdata <- data.frame(arm=0:1) St <- survfit(bayes, newdata) plot(ekm, col=1:2) with(St, lines(time, surv[[1]])) with(St, lines(time, surv[[2]], col=2))
This function extracts and returns the variance-covariance matrix associated with the regression coefficients when the maximum likelihood estimation approach is used in the model fitting.
## S3 method for class 'ypbp' vcov(object, ...)
## S3 method for class 'ypbp' vcov(object, ...)
object |
an object of the class ypbp. |
... |
further arguments passed to or from other methods. |
the variance-covariance matrix associated with the regression coefficients.
Fits the Yang and Prentice model with either the baseline hazard hazard or the baseline odds modeled via Bernstein polynomials.
ypbp( formula, data, degree = NULL, tau = NULL, approach = c("mle", "bayes"), baseline = c("hazard", "odds"), hessian = TRUE, 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), ... )
ypbp( formula, data, degree = NULL, tau = NULL, approach = c("mle", "bayes"), baseline = c("hazard", "odds"), hessian = TRUE, 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), ... )
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 ypbp is called. |
degree |
number of intervals of the PE distribution. If NULL, default value (square root of n) is used. |
tau |
the maximum time of follow-up. If NULL, tau = max(time), where time is the vector of observed survival times. |
approach |
approach to be used to fit the model (mle: maximum likelihood; bayes: Bayesian approach). |
baseline |
baseline function to be modeled. |
hessian |
logical; If TRUE (default), the hessian matrix is returned when approach="mle". |
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' . |
ypbp returns an object of class "ypbp" containing the fitted model.
library(YPBP) mle1 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "hazard") mle2 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "odds") bayes1 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "hazard", approach = "bayes", chains = 2, iter = 500) bayes2 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "odds", approach = "bayes", chains = 2, iter = 500)
library(YPBP) mle1 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "hazard") mle2 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "odds") bayes1 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "hazard", approach = "bayes", chains = 2, iter = 500) bayes2 <- ypbp(Surv(time, status)~trt, data=gastric, baseline = "odds", approach = "bayes", chains = 2, iter = 500)