| Title: | Bernstein Polynomial Based Semiparametric Survival Analysis |
|---|---|
| Description: | Semiparametric survival analysis based on Bernstein polynomials. 'spsurv' includes proportional hazards, proportional odds and accelerated failure time frameworks for right-censored data. RV Panaro (2020) <arXiv:2003.10548>. |
| Authors: | Renato Panaro [aut, cre, cph], Fábio Demarqui [ctb, ths], Vinicius Mayrink [ths] |
| Maintainer: | Renato Panaro <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.2 |
| Built: | 2026-07-05 13:51:49 UTC |
| Source: | https://github.com/rvpanaro/spsurv |
A set of flexible routines to allow semiparametric survival regression modeling based on Bernstein polynomial, including Bernstein based proportinal hazards model (BPPH), Bernstein polynomial based proportional odds model (BPPO) and Bernstein based accelerated failure time model (BPAFT) for right-censored data.
spbp fits semi-parametric models for time-to-event survival data.
Non-informative right-censoring assumption is available. Any user-defined Bernstein polynomial can
be user-defined using an arbitrary degree, i.e. highest basis polynomials order.
The framework takes advantage of fully likelihood methods since the polynomial parameters are used to estimate the baseline functions. Even so, this is said to be semi-parametric since this approach does not rely on any distribution. Unlike the Cox model, the BP based models provide smooth hazard and survival curve estimates.
_PACKAGE
none
Panaro R.V. (2020). spsurv: An R package for semi-parametric survival analysis. arXiv preprint arXiv:2003.10548.
Demarqui, F. N., & Mayrink, V. D. (2019). A fully likelihood-based approach to model survival data with crossing survival curves. arXiv preprint arXiv:1910.02406.
Demarqui, F. N., Mayrink, V. D., & Ghosh, S. K. (2019). An Unified Semiparametric Approach to Model Lifetime Data with Crossing Survival Curves. arXiv preprint arXiv:1910.04475.
Osman, M., & Ghosh, S. K. (2012). Nonparametric regression models for right-censored data using Bernstein polynomials. Computational Statistics & Data Analysis, 56(3), 559-573.
Lorentz, G. G. (1953). Bernstein polynomials. American Mathematical Society.
Bernstein basis polynomials calculations
bp.basis(time, degree, tau = max(time))bp.basis(time, degree, tau = max(time))
time |
a vector of times. |
degree |
Bernstein polynomial degree |
tau |
must be greater than times maximum value observed. |
A list containing matrices g and G corresponding BP basis and corresponding tau value used to compute them.
Fits the BPAFT model to time-to-event data.
bpaft(formula, degree, data, approach = c("mle", "bayes"), ...)bpaft(formula, degree, data, approach = c("mle", "bayes"), ...)
formula |
a Surv object with time to event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. |
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
... |
further arguments passed to or from other methods |
An object of class 'spbp'.
spbp, bpph and bppo for other BP based models.
library("spsurv") data("veteran", package = "survival") fit <- bpaft(Surv(time, status) ~ karno + celltype, data = veteran ) summary(fit)library("spsurv") data("veteran", package = "survival") fit <- bpaft(Surv(time, status) ~ karno + celltype, data = veteran ) summary(fit)
Fits the BPPH model to time-to-event data.
bpph(formula, degree, data, approach = c("mle", "bayes"), ...)bpph(formula, degree, data, approach = c("mle", "bayes"), ...)
formula |
a Surv object with time to event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. |
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
... |
further arguments passed to or from other methods |
An object of class 'spbp'.
spbp, bppo and bpaft for other BP based models.
library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) summary(fit)library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) summary(fit)
Fits the BPPO model to time-to-event data.
bppo(formula, degree, data, approach = c("mle", "bayes"), ...)bppo(formula, degree, data, approach = c("mle", "bayes"), ...)
formula |
a Surv object with time-to-event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. |
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
... |
further arguments passed to or from other methods |
An object of class 'spbp'.
spbp, bpph and bpaft for other BP based models.
library("spsurv") data("veteran", package = "survival") fit <- bppo(Surv(time, status) ~ karno + celltype, data = veteran ) summary(fit)library("spsurv") data("veteran", package = "survival") fit <- bppo(Surv(time, status) ~ karno + celltype, data = veteran ) summary(fit)
Estimated regression coefficients
## S3 method for class 'spbp' coef(object, summary = c("mean", "median", "mode"), ...)## S3 method for class 'spbp' coef(object, summary = c("mean", "median", "mode"), ...)
object |
an object of the class spbp |
summary |
posterior summary if method ="bayes" in x |
... |
further arguments passed to or from other methods |
the estimated regression coefficients
Confidence intervals for the regression coefficients
## S3 method for class 'spbp' confint(object, parm = names(coef(object)), level = 0.95, ...)## S3 method for class 'spbp' confint(object, parm = names(coef(object)), level = 0.95, ...)
object |
a fitted model object. |
parm |
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered. |
level |
the confidence level required. |
... |
further arguments passed to parent method |
100(1-alpha) confidence intervals for the regression coefficients
Generic S3 method credint
credint(x, ...)credint(x, ...)
x |
a fitted model object |
... |
further arguments passed to parent method |
the estimated regression coefficients
Confidence intervals for the regression coefficients
## S3 method for class 'spbp' credint(x, prob = 0.95, type = c("HPD", "Equal-Tailed"), ...)## S3 method for class 'spbp' credint(x, prob = 0.95, type = c("HPD", "Equal-Tailed"), ...)
x |
an object of the class x. |
prob |
the probability level required. |
type |
interval type. |
... |
further arguments passed to or from other methods. |
100(1-alpha) confidence intervals for the regression coefficients
Model.matrix of a fitted spbp model.
## S3 method for class 'spbp' model.matrix(object, ...)## S3 method for class 'spbp' model.matrix(object, ...)
object |
an object of class 'spbp', see |
... |
arguments passed to parent method. |
The model matrix.
library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) model.matrix(fit)library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) model.matrix(fit)
Plot for a fitted spbp model.
## S3 method for class 'spbp' plot( x, main, graph = c("baseline", "basis"), cumulative = F, frame = F, lwd = 3, ... )## S3 method for class 'spbp' plot( x, main, graph = c("baseline", "basis"), cumulative = F, frame = F, lwd = 3, ... )
x |
an object of class 'spbp' result of a |
main |
graph title |
graph |
type of polynomial graph, default is "basis" |
cumulative |
TRUE for odds and cumulative hazard |
frame |
graphical parameter; default is FALSE |
lwd |
graphical parameter; default is 3 |
... |
further arguments passed to or from other methods |
spbp.
library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) plot(fit)library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) plot(fit)
Bernstein Polynomial Based Regression Object Print
## S3 method for class 'spbp' print( x, bp.param = FALSE, digits = max(getOption("digits") - 4, 3), signif.stars = getOption("show.signif.stars"), ... )## S3 method for class 'spbp' print( x, bp.param = FALSE, digits = max(getOption("digits") - 4, 3), signif.stars = getOption("show.signif.stars"), ... )
x |
an object of class spbp. |
bp.param |
print BP parameters. |
digits |
number of digits to display. |
signif.stars |
see |
... |
further arguments passed to or from other methods. |
none
Bernstein Polynomial Based Regression Object Summary BPAFT Bayes
## S3 method for class 'summary.bpaft.bayes' print(...)## S3 method for class 'summary.bpaft.bayes' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary BPAFT MLE
## S3 method for class 'summary.bpaft.mle' print(...)## S3 method for class 'summary.bpaft.mle' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary BPPH Bayes
## S3 method for class 'summary.bpph.bayes' print(...)## S3 method for class 'summary.bpph.bayes' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary BPPH MLE
## S3 method for class 'summary.bpph.mle' print(...)## S3 method for class 'summary.bpph.mle' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary BPPO Bayes
## S3 method for class 'summary.bppo.bayes' print(...)## S3 method for class 'summary.bppo.bayes' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object BPPO MLE
## S3 method for class 'summary.bppo.mle' print(...)## S3 method for class 'summary.bppo.mle' print(...)
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary Bayes
## S3 method for class 'summary.spbp.bayes' print(x, digits = max(getOption("digits") - 4, 3), ...)## S3 method for class 'summary.spbp.bayes' print(x, digits = max(getOption("digits") - 4, 3), ...)
x |
a summary.spbp.bayes object |
digits |
number of digits to display. |
... |
further arguments passed to or from other methods |
none
Bernstein Polynomial Based Regression Object Summary MLE
## S3 method for class 'summary.spbp.mle' print( x, digits = max(getOption("digits") - 4, 3), signif.stars = getOption("show.signif.stars"), ... )## S3 method for class 'summary.spbp.mle' print( x, digits = max(getOption("digits") - 4, 3), signif.stars = getOption("show.signif.stars"), ... )
x |
a summary.spbp.mle object |
digits |
number of digits to display. |
signif.stars |
see |
... |
further arguments passed to or from other methods |
none
Power basis polynomials calculations
pw.basis(degree)pw.basis(degree)
degree |
Bernstein polynomial degree |
A list containing matrices g and G corresponding BP basis and corresponding tau value used to compute them.
Residuals for a fitted spbp model.
## S3 method for class 'spbp' residuals(object, type = c("martingale", "deviance", "coobject-snell"), ...)## S3 method for class 'spbp' residuals(object, type = c("martingale", "deviance", "coobject-snell"), ...)
object |
an object of class 'spbp' result of a |
type |
type of residuals, default is "cox-snell" |
... |
arguments passed to parent method. |
library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) residuals(fit)library("spsurv") data("veteran", package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran ) residuals(fit)
Semiparametric Survival Analysis Using Bernstein Polynomial
spbp(formula, ...)spbp(formula, ...)
formula |
a Surv object with time to event, status and explanatory terms. |
... |
Arguments passed to 'rstan::sampling' (e.g. iter, chains) or 'rstan::optimizing'. |
Fits Bernstein Polynomial based Proportional regression to survival data.
An object of class 'spbp'.
spbp.default, bpph, bppo, bpaft, https://mc-stan.org/users/documentation/
library("spsurv") data("veteran", package = "survival") fit_mle <- spbp(Surv(time, status) ~ karno + factor(celltype), data = veteran, model = "po" ) summary(fit_mle) fit_bayes <- spbp(Surv(time, status) ~ karno + factor(celltype), data = veteran, model = "po", approach = "bayes", cores = 1, iter = 300, chains = 1, priors = list( beta = c("normal(0,5)"), gamma = "halfnormal(0,5)" ) ) summary(fit_bayes)library("spsurv") data("veteran", package = "survival") fit_mle <- spbp(Surv(time, status) ~ karno + factor(celltype), data = veteran, model = "po" ) summary(fit_mle) fit_bayes <- spbp(Surv(time, status) ~ karno + factor(celltype), data = veteran, model = "po", approach = "bayes", cores = 1, iter = 300, chains = 1, priors = list( beta = c("normal(0,5)"), gamma = "halfnormal(0,5)" ) ) summary(fit_bayes)
spbp: The BP Based Semiparametric Survival Analysis Function
## Default S3 method: spbp( formula, degree, data, approach = c("mle", "bayes"), model = c("ph", "po", "aft"), priors = list(beta = c("normal(0,4)"), gamma = c("lognormal(0,4)"), frailty = c("gamma(0.01,0.01)")), cores = min(parallel::detectCores() - 1, 4), scale = TRUE, verbose = FALSE, chains = 4, ... )## Default S3 method: spbp( formula, degree, data, approach = c("mle", "bayes"), model = c("ph", "po", "aft"), priors = list(beta = c("normal(0,4)"), gamma = c("lognormal(0,4)"), frailty = c("gamma(0.01,0.01)")), cores = min(parallel::detectCores() - 1, 4), scale = TRUE, verbose = FALSE, chains = 4, ... )
formula |
a Surv object with time to event, status and explanatory terms |
degree |
Bernstein Polynomial degree |
data |
a data.frame object |
approach |
Bayesian or Maximum Likelihood estimation methods, default is approach = "bayes" |
model |
Proportional Hazards or Proportional Odds BP based regression, default is model = "ph" |
priors |
prior settings for the Bayesian approach; 'normal' or 'cauchy' for beta; 'lognormal' or 'loglogistic' for gamma (BP coefficients) |
cores |
number of core threads to use |
scale |
logical; indicates whether to center and scale the data |
verbose |
verbose passed to stan |
chains |
number of chains passed to stan |
... |
further arguments passed to or from other methods |
An object of class spbp
Bernstein Polynomial Based Regression Object Summary
## S3 method for class 'spbp' summary(object, interval = 0.95, ...)## S3 method for class 'spbp' summary(object, interval = 0.95, ...)
object |
an object of class spbp |
interval |
interval coverage (confidence or credibility) |
... |
further arguments passed to or from other methods |
An object of class analogous to for e.g. 'summary.bppo.bayes'.
Compute survival curves for a fitted spbp model.
## S3 method for class 'spbp' survfit( formula, newdata, times, se.fit = TRUE, interval = 0.95, type = c("log", "log-log", "plain"), ... )## S3 method for class 'spbp' survfit( formula, newdata, times, se.fit = TRUE, interval = 0.95, type = c("log", "log-log", "plain"), ... )
formula |
An object of class |
newdata |
Optional data frame used to obtain survival curves for specific covariate values. |
times |
Optional numeric vector of time points at which to return estimates. |
se.fit |
Logical; if |
interval |
Confidence level for intervals (e.g. |
type |
Character; confidence interval transformation. One of |
... |
Further arguments (currently ignored or reserved for future use). |
An object of class "survfit".
library(spsurv) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran) survfit(fit)library(spsurv) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran) survfit(fit)
Uses block-wise inversion of the negative Hessian, with a clear split between the regression coefficients (beta) and the Bernstein polynomial coefficients (gamma).
## S3 method for class 'spbp' vcov(object, bp.param = FALSE, ...)## S3 method for class 'spbp' vcov(object, bp.param = FALSE, ...)
object |
an object of the class spbp |
bp.param |
return Bernstein Polynomial variance. |
... |
arguments passed to parent method. |
the variance-covariance matrix associated with the regression coefficients.