| 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) <doi:10.48550/arXiv.2003.10548>. |
| Authors: | Renato Panaro [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-1903-2091>, URL: https://rvpanaro.github.io/), Fábio Demarqui [ths, rev] (ORCID: <https://orcid.org/0000-0001-9236-1986>, URL: http://www.est.ufmg.br/~fndemarqui/), Vinicius Mayrink [ths] (ORCID: <https://orcid.org/0000-0002-5683-8326>, URL: http://www.est.ufmg.br/~vdinizm/) |
| Maintainer: | Renato Panaro <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1.0 |
| Built: | 2026-10-28 12:21:03 UTC |
| Source: | https://github.com/cran/spsurv |
A set of flexible routines to allow semiparametric survival regression modeling based on Bernstein polynomial, including Bernstein PH model (BPPH), Bernstein PO model (BPPO), and Bernstein AFT 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.
For Bayesian fits, users should routinely inspect divergences, split-,
and effective sample sizes, and tighten NUTS controls (e.g., increasing
adapt_delta, iter, and warmup) when warnings are present.
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.
Akaike information criterion for fitted spbp models
## S3 method for class 'spbp' AIC(object, ..., k = 2)## S3 method for class 'spbp' AIC(object, ..., k = 2)
object |
A fitted |
... |
Additional fitted models for comparison. |
k |
Penalty per parameter (default 2). |
Compare nested MLE fits. With one model, builds a sequential table by refitting
intercept-only and nested submodels along the formula term order (same idea as
anova(fit) for survreg). With multiple models,
compares each consecutive pair (same convention as
anova(fit0, fit1) for survreg).
## S3 method for class 'spbp' anova(object, ..., test = "Chisq")## S3 method for class 'spbp' anova(object, ..., test = "Chisq")
object |
A fitted |
... |
Additional nested fitted models (MLE, same family recommended). |
test |
Which test to report (only |
An "anova" object (also a data.frame). Pairwise
comparisons use Terms, Resid. Df, -2*LL, Test,
Df, Deviance, and Pr(>Chi) columns (as in
survival::survreg). Sequential single-model tables use
Df, Deviance, Resid. Df, -2*LL, and
Pr(>Chi) with row names NULL and term labels.
Convert spbp Bayesian fit to posterior draws
as_draws_df.spbp(x, variables = c("beta", "gamma"), ...)as_draws_df.spbp(x, variables = c("beta", "gamma"), ...)
x |
A fitted |
variables |
Character vector of posterior components to include
( |
... |
Not used. |
A posterior::draws_df object on the back-transformed scale.
Add fitted values, residuals, and optional survival predictions to the training (or supplied) data.
## S3 method for class 'spbp' augment( x, data = NULL, eval_time = NULL, type = c("martingale", "deviance", "cox-snell", "coxsnell"), ... )## S3 method for class 'spbp' augment( x, data = NULL, eval_time = NULL, type = c("martingale", "deviance", "cox-snell", "coxsnell"), ... )
x |
A fitted |
data |
Optional data frame; defaults to the training data when available. |
eval_time |
Optional numeric vector of times for nested survival
predictions (same structure as |
type |
Residual type passed to |
... |
Not used. |
A data.frame with original rows plus .residual and,
when eval_time is set, a list-column .pred.
Helper for specifying a Bernstein polynomial baseline via the
dist / baseline arguments accepted by spbp.
bernstein(m = NULL)bernstein(m = NULL)
m |
Bernstein polynomial degree (number of basis coefficients). |
A list with components baseline and m.
bernstein(5)bernstein(5)
Convenience constructor mapping family to the appropriate
parsnip model (proportional_hazards, proportional_odds, or
survival_reg).
bp_survival_reg( family = c("ph", "po", "aft"), mode = "censored regression", engine = "spsurv" )bp_survival_reg( family = c("ph", "po", "aft"), mode = "censored regression", engine = "spsurv" )
family |
Model family: |
mode |
Model mode (default |
engine |
parsnip engine (default |
A parsnip model specification.
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 = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )bpaft( formula, degree = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )
formula |
a Surv object with time to event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. If omitted, defaults to
|
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
dist |
optional baseline specification; use |
baseline |
optional alias for |
... |
further arguments passed to or from other methods |
An object of class spbp, including component degree.
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 = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )bpph( formula, degree = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )
formula |
a Surv object with time to event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. If omitted, defaults to
|
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
dist |
optional baseline specification; use |
baseline |
optional alias for |
... |
further arguments passed to or from other methods |
An object of class spbp, including component degree.
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 = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )bppo( formula, degree = NULL, data, approach = c("mle", "bayes"), dist = NULL, baseline = NULL, ... )
formula |
a Surv object with time-to-event observations, right censoring status and explanatory terms. |
degree |
Bernstein polynomial degree. If omitted, defaults to
|
data |
a data.frame object. |
approach |
Bayesian or maximum likelihood estimation methods, default is approach = "mle". |
dist |
optional baseline specification; use |
baseline |
optional alias for |
... |
further arguments passed to or from other methods |
An object of class spbp, including component degree.
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, level = 0.95, ...)## S3 method for class 'spbp' confint(object, parm, level = 0.95, ...)
object |
a fitted model object. |
parm |
a specification of which parameters are to be given confidence
intervals: regression coefficient names and/or Bernstein baseline names
(e.g. |
level |
the confidence level required. |
... |
further arguments passed to parent method |
100(1-alpha) confidence intervals for the requested parameters.
Generic S3 method credint
credint(x, ...)credint(x, ...)
x |
a fitted model object |
... |
further arguments passed to parent method |
Generic function dispatching to credint.spbp.
Credible 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) credible intervals for the regression coefficients
Parameter estimates for fitted spbp models
estimates(object, ...)estimates(object, ...)
object |
A fitted |
... |
Not used. |
Named numeric vector of regression and Bernstein-polynomial parameters.
Extract AIC from a fitted spbp model
## S3 method for class 'spbp' extractAIC(fit, scale = 0, k = 2, ...)## S3 method for class 'spbp' extractAIC(fit, scale = 0, k = 2, ...)
fit |
A fitted |
scale |
Not used. |
k |
Penalty per parameter (default 2). |
... |
Not used. |
Convenience wrapper around residuals.spbp that returns a
ggplot2 object for martingale, deviance, or Cox-Snell residuals.
ggresiduals( object, type = c("martingale", "deviance", "cox-snell", "coxsnell"), against = c("fitted", "index"), ... )ggresiduals( object, type = c("martingale", "deviance", "cox-snell", "coxsnell"), against = c("fitted", "index"), ... )
object |
A fitted |
type |
Residual type: |
against |
What to plot on the x-axis: |
... |
Further arguments passed to |
A ggplot object (requires ggplot2).
## Not run: library(spsurv) library(ggplot2) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, degree = 4) ggresiduals(fit, type = "martingale") ## End(Not run)## Not run: library(spsurv) library(ggplot2) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, degree = 4) ggresiduals(fit, type = "martingale") ## End(Not run)
Return a one-row broom/generics-style summary of model-level statistics.
## S3 method for class 'spbp' glance(x, ...)## S3 method for class 'spbp' glance(x, ...)
x |
A fitted |
... |
Currently unused. |
A one-row data.frame with model-level statistics. Columns
that are entirely NA for the fitted object are omitted.
Log-likelihood for fitted spbp models
## S3 method for class 'spbp' logLik(object, ...)## S3 method for class 'spbp' logLik(object, ...)
object |
A fitted |
... |
Not used. |
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 = FALSE, frame = FALSE, lwd = 3, ... )## S3 method for class 'spbp' plot( x, main, graph = c("baseline", "basis"), cumulative = FALSE, frame = FALSE, 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)
Survival (and optional CI) on a time grid, as a data.frame for
ggplot2::geom_line.
## S3 method for class 'spbp' predict( object, newdata = NULL, times = NULL, eval_time = NULL, type = NULL, conf_type = NULL, interval = 0.95, interval.type = c("hpd", "quantile"), monotone = NULL, ... )## S3 method for class 'spbp' predict( object, newdata = NULL, times = NULL, eval_time = NULL, type = NULL, conf_type = NULL, interval = 0.95, interval.type = c("hpd", "quantile"), monotone = NULL, ... )
object |
|
newdata |
Optional |
times |
Time grid. Default: a dense sequence from 0 to the maximum observed
time (suitable for smooth |
eval_time |
Evaluation times for |
type |
Prediction type. For tidymodels/censored compatibility use
|
conf_type |
Confidence interval transformation for curve predictions
( |
interval |
Confidence level for curve predictions; passed to
|
interval.type, monotone
|
Passed to |
... |
Passed to |
For curve predictions, same structure as as.data.frame.survfitbp.
For type = "survival", a tibble with list-column .pred (elements
contain .eval_time and .pred_survival). For type = "time",
a tibble with .pred_time. For type = "linear_pred", a tibble with
.pred_linear_pred.
data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, approach = "mle", init = 0) pr <- predict(fit, times = seq(0, 400, by = 2)) predict(fit, veteran[1:2, ], type = "survival", eval_time = c(100, 200)) predict(fit, veteran[1:2, ], type = "time") ## Not run: ggplot2::ggplot(pr, ggplot2::aes(time, surv)) + ggplot2::geom_line() ## End(Not run)data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, approach = "mle", init = 0) pr <- predict(fit, times = seq(0, 400, by = 2)) predict(fit, veteran[1:2, ], type = "survival", eval_time = c(100, 200)) predict(fit, veteran[1:2, ], type = "time") ## Not run: ggplot2::ggplot(pr, ggplot2::aes(time, surv)) + ggplot2::geom_line() ## End(Not run)
Bernstein Polynomial Based Regression Object Print
## S3 method for class 'spbp' print( x, bp.param = FALSE, show_baseline = FALSE, digits = 2, signif.stars = getOption("show.signif.stars"), what = "summary", ... )## S3 method for class 'spbp' print( x, bp.param = FALSE, show_baseline = FALSE, digits = 2, signif.stars = getOption("show.signif.stars"), what = "summary", ... )
x |
an object of class spbp. |
bp.param |
print BP parameters only (alias for baseline-only display). |
show_baseline |
logical; append Bernstein baseline Wald table after
regression coefficients (MLE only). See also |
digits |
number of digits to display; defaults to |
signif.stars |
see |
what |
character vector; any of |
... |
further arguments passed to |
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 = 2, signif.stars = getOption("show.signif.stars"), ...)## S3 method for class 'summary.spbp.bayes' print(x, digits = 2, signif.stars = getOption("show.signif.stars"), ...)
x |
a summary.spbp.bayes object |
digits |
number of digits to display. |
signif.stars |
see |
... |
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 = 2, signif.stars = getOption("show.signif.stars"), ...)## S3 method for class 'summary.spbp.mle' print(x, digits = 2, 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
Proportional odds survival regression with a Bernstein polynomial baseline
(bppo). This model type is registered by spsurv for use
with tidymodels; it is not part of the censored package.
proportional_odds(mode = "censored regression", engine = "spsurv")proportional_odds(mode = "censored regression", engine = "spsurv")
mode |
A single character string for the prediction outcome mode. The only possible value for this model is "censored regression". |
engine |
A single character string specifying what computational engine to use for fitting. |
A model specification.
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.
Convenience wrapper around AIC that returns models sorted from
lowest to highest AIC.
rank_models(...)rank_models(...)
... |
One or more fitted |
A data.frame with columns fit, model,
degree, aic, and npars.
## Not run: library(spsurv) data(veteran, package = "survival") f1 <- bpph(Surv(time, status) ~ 1, data = veteran, degree = 4) f2 <- bpph(Surv(time, status) ~ karno, data = veteran, degree = 4) rank_models(f1, f2) ## End(Not run)## Not run: library(spsurv) data(veteran, package = "survival") f1 <- bpph(Surv(time, status) ~ 1, data = veteran, degree = 4) f2 <- bpph(Surv(time, status) ~ karno, data = veteran, degree = 4) rank_models(f1, f2) ## End(Not run)
Residuals for a fitted spbp model.
## S3 method for class 'spbp' residuals( object, type = c("martingale", "deviance", "cox-snell", "coxsnell"), ... )## S3 method for class 'spbp' residuals( object, type = c("martingale", "deviance", "cox-snell", "coxsnell"), ... )
object |
an object of class 'spbp' result of a |
type |
type of residuals; default is |
... |
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)
Standard errors for fitted spbp model parameters
se(object, ...)se(object, ...)
object |
A fitted |
... |
Not used. |
Named numeric vector of standard errors aligned with estimates.
Semiparametric Survival Analysis Using Bernstein Polynomial
spbp(formula, ...)spbp(formula, ...)
formula |
a |
... |
Arguments passed to |
Fits Bernstein PH, PO, or AFT models to survival data via Stan (MLE or Bayesian).
The generic dispatches to spbp.default for formula objects.
Convenience wrappers bpph, bppo, and
bpaft fix the model family. See
vignette("getting-started", package = "spsurv") for a tutorial,
vignette("model-families", package = "spsurv") for PH / PO / AFT
comparison, and vignette("bp-degree", package = "spsurv") for
choosing the Bernstein polynomial degree.
An object of class "spbp". See spbp.default for
the list of components (coefficients, bp.param,
degree, etc.).
spbp.default, bpph, bppo,
bpaft, bernstein
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,2)"), gamma = c("lognormal(0,4)"), frailty = c("gamma(0.01,0.01)")), cores = .spbp_default_cores(), scale = TRUE, dist = NULL, baseline = NULL, 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,2)"), gamma = c("lognormal(0,4)"), frailty = c("gamma(0.01,0.01)")), cores = .spbp_default_cores(), scale = TRUE, dist = NULL, baseline = NULL, verbose = FALSE, chains = 4, ... )
formula |
a Surv object with time to event, status and explanatory terms |
degree |
Bernstein polynomial degree (integer). If omitted and neither
|
data |
a data.frame object |
approach |
Bayesian or Maximum Likelihood estimation methods; default is |
model |
Bernstein PH ( |
priors |
prior settings for the Bayesian approach; 'normal' or 'cauchy' for beta; 'lognormal' or 'loglogistic' for gamma (BP coefficients). Defaults are |
cores |
number of core threads to use (Bayes sampling) |
scale |
logical; indicates whether to center and scale the data |
dist |
optional baseline specification; use |
baseline |
optional alias for |
verbose |
passed to Stan |
chains |
number of MCMC chains (Bayes) |
... |
further arguments passed to |
Right-censored survival data are modeled with a Bernstein-polynomial baseline
and regression on covariates. With approach = "mle", parameters are
estimated by Stan's optimizer and approximate inference uses the Hessian when
available. With approach = "bayes", posterior samples are drawn with
NUTS; use summary, tidy.spbp, and glance.spbp
for output. Covariates are centered and scaled when scale = TRUE
(default).
The returned object includes:
coefficientsRegression estimates on the original covariate scale.
bp.paramBernstein baseline coefficients (gamma).
degreePolynomial degree used (also in call$degree).
loglikMLE: intercept-only and full-model log-likelihoods; Bayes: posterior mean pointwise log-likelihoods.
callMatched call with approach, model, and degree.
An object of class spbp. Component degree records the
Bernstein polynomial degree used in the fit (also stored in call$degree).
bpph, bppo, bpaft,
bernstein, summary.spbp
Posterior survival curves in long tidy format
spread_surv_draws.spbp(object, times, newdata = NULL, ...)spread_surv_draws.spbp(object, times, newdata = NULL, ...)
object |
A Bayesian |
times |
Numeric vector of evaluation times. |
newdata |
Optional covariate profiles. |
... |
Not used. |
A data.frame with .chain, .iteration, .draw,
time, surv, and optional covariate columns.
Bernstein Polynomial Based Regression Object Summary
## S3 method for class 'spbp' summary( object, interval = 0.95, compact = TRUE, show_call = TRUE, show_intervals = TRUE, show_baseline = FALSE, mle_test = c("lr", "wald"), bayes_criterion = c("waic", "dic", "lpml"), ... )## S3 method for class 'spbp' summary( object, interval = 0.95, compact = TRUE, show_call = TRUE, show_intervals = TRUE, show_baseline = FALSE, mle_test = c("lr", "wald"), bayes_criterion = c("waic", "dic", "lpml"), ... )
object |
an object of class spbp |
interval |
interval coverage (confidence or credibility) |
compact |
logical; if TRUE, print.summary methods show essential output only. |
show_call |
logical; include the model call in printed summary. |
show_intervals |
logical; include interval table in printed summary. |
show_baseline |
logical; include Bernstein baseline ( |
mle_test |
global test to print for MLE summaries: "lr" or "wald". |
bayes_criterion |
global criterion to print for Bayesian summaries: "waic", "dic", or "lpml". |
... |
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 = NULL, times = NULL, se.fit = TRUE, interval = 0.95, type = c("log", "log-log", "plain"), interval.type = c("hpd", "quantile"), monotone = NULL, tidy = FALSE, baseline = FALSE, ... ) ## S3 method for class 'survfitbp' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'survfitbp' plot( x, conf.int, col = 1, lty = 1, lwd = 1.5, xlab = "Time", ylab = "Survival probability", ylim = c(0, 1), mark.time = FALSE, ... )## S3 method for class 'spbp' survfit( formula, newdata = NULL, times = NULL, se.fit = TRUE, interval = 0.95, type = c("log", "log-log", "plain"), interval.type = c("hpd", "quantile"), monotone = NULL, tidy = FALSE, baseline = FALSE, ... ) ## S3 method for class 'survfitbp' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'survfitbp' plot( x, conf.int, col = 1, lty = 1, lwd = 1.5, xlab = "Time", ylab = "Survival probability", ylim = c(0, 1), mark.time = FALSE, ... )
formula |
An object of class |
newdata |
Optional data frame used to obtain survival curves for specific covariate values. |
times |
Optional evaluation times: a |
se.fit |
Logical; if |
interval |
Confidence level for intervals (e.g. |
type |
Character; confidence interval transformation. One of |
interval.type |
For Bayesian fits only: |
monotone |
Logical; for Bayesian fits, enforce non-increasing credible-band limits over
time so ribbons plot smoothly with |
tidy |
Logical; if |
baseline |
Logical; if |
... |
Further arguments passed to |
x |
Object from |
row.names, optional
|
Unused; included for S3 consistency. |
conf.int |
Logical; draw pointwise interval limits. Defaults to
|
col, lty, lwd, xlab, ylab, ylim
|
Graphical parameters. |
mark.time |
Ignored (Bernstein curves are continuous). |
An object of class "survfit" (with classes survfitbp, survfitcox, survfit).
A data.frame with columns id (curve index), time, surv,
lower, upper, cumhaz, std.err.
as.data.frame(survfitbp): Tidy survival curves for ggplot2::geom_line / geom_ribbon.
plot(survfitbp): Plot Bernstein-polynomial survival as a smooth line
(type = "l"), never a Kaplan–Meier step function. Pass
conf.int = TRUE for pointwise bands (also drawn with lines).
spbp, survfit,
predict.spbp, survfit.spbp (as.data.frame method).
library(spsurv) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran) survfit(fit) plot(survfit(fit, times = seq(0, max(veteran$time), length.out = 80))) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, approach = "mle", init = 0) sf <- survfit(fit, times = seq(0, max(veteran$time), length.out = 80)) head(as.data.frame(sf))library(spsurv) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran) survfit(fit) plot(survfit(fit, times = seq(0, max(veteran$time), length.out = 80))) data(veteran, package = "survival") fit <- bpph(Surv(time, status) ~ karno, data = veteran, approach = "mle", init = 0) sf <- survfit(fit, times = seq(0, max(veteran$time), length.out = 80)) head(as.data.frame(sf))
Create a broom/generics-style tidy data frame with one row per model term.
## S3 method for class 'spbp' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, component = c("coef", "baseline", "all"), ... )## S3 method for class 'spbp' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, component = c("coef", "baseline", "all"), ... )
x |
A fitted |
conf.int |
Logical; include confidence/credible interval columns. |
conf.level |
Interval coverage level. |
exponentiate |
Logical; if |
component |
Which parameters to return: |
... |
Currently unused. |
A data.frame with columns term, estimate,
std.error, and when available statistic, p.value,
conf.low, conf.high. Columns that are entirely
NA are omitted.
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, mask_unstable_gamma = TRUE, ...)## S3 method for class 'spbp' vcov(object, bp.param = FALSE, mask_unstable_gamma = TRUE, ...)
object |
an object of the class spbp |
bp.param |
return Bernstein Polynomial variance. |
mask_unstable_gamma |
when |
... |
arguments passed to parent method. |
the variance-covariance matrix associated with the regression coefficients.