| Type: | Package |
| Title: | Bernstein Polynomial Based Semiparametric Survival Analysis |
| Version: | 1.1.0 |
| 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>. |
| License: | GPL-3 |
| Biarch: | true |
| Depends: | R (≥ 4.1.0), survival (≥ 2.44-1.1), coda (≥ 0.19-3) |
| Imports: | methods, Rcpp (≥ 0.12.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), generics, viridis |
| LinkingTo: | BH (≥ 1.66.0), Rcpp (≥ 0.12.0), RcppEigen (≥ 0.3.3.3.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), StanHeaders (≥ 2.18.0) |
| Suggests: | testthat (≥ 2.1.0), knitr, rmarkdown (≥ 2.31), ggplot2 (≥ 3.3.0), KMsurv, parsnip (≥ 1.0.0), censored (≥ 0.3.0), workflows (≥ 1.1.0), tidybayes (≥ 3.0.0), posterior (≥ 1.4.0), covr, rsample (≥ 1.1.0), rsurv, rstantools (≥ 1.5.1) |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| SystemRequirements: | GNU make |
| BugReports: | https://github.com/rvpanaro/spsurv/issues |
| URL: | https://github.com/rvpanaro/spsurv, https://rvpanaro.github.io/spsurv/ |
| Config/roxygen2/version: | 8.0.0 |
| Config/rstantools/auto_config: | FALSE |
| NeedsCompilation: | yes |
| Packaged: | 2026-09-28 07:43:22 UTC; rvpanaro |
| Author: | Renato Panaro |
| Maintainer: | Renato Panaro <rvpanaro@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-28 09:00:02 UTC |
The 'spsurv' package.
Description
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.
Details
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-\hat R,
and effective sample sizes, and tighten NUTS controls (e.g., increasing
adapt_delta, iter, and warmup) when warnings are present.
Value
none
Author(s)
rvpanaro@gmail.com
References
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.
Internal: Calculate the posterior mode
Description
Internal: Calculate the posterior mode
Usage
.mode(ext)
Internal: AFT basis evaluator aligned with Stan transformed parameters
Description
Internal: AFT basis evaluator aligned with Stan transformed parameters
Usage
.spbp_aft_basis(time_aft, tau_a, tau_b, P)
Arguments
time_aft |
Numeric vector of AFT residual-scale times y = log(t) - eta. |
tau_a |
Lower bound used by the fitted model. |
tau_b |
Upper bound used by the fitted model. |
P |
Power-basis transformation matrix from |
Value
list(g = ..., G = ...) where g is hazard basis and
G is cumulative-hazard basis on the AFT residual scale.
Bayesian fit for spbp (internal)
Description
Bayesian fit for spbp (internal)
Usage
.spbp_bayes(standata, hessian = FALSE, verbose = FALSE, chains = 1, ...)
Internal: compute survival CI bands (survfit-style)
Description
Internal: compute survival CI bands (survfit-style)
Usage
.survfit_confint(
p,
se,
logse = TRUE,
conf.type,
conf.int,
selow,
ulimit = TRUE
)
Akaike information criterion for fitted spbp models
Description
Akaike information criterion for fitted spbp models
Usage
## S3 method for class 'spbp'
AIC(object, ..., k = 2)
Arguments
object |
A fitted |
... |
Additional fitted models for comparison. |
k |
Penalty per parameter (default 2). |
Analysis of deviance table for nested spbp models
Description
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).
Usage
## S3 method for class 'spbp'
anova(object, ..., test = "Chisq")
Arguments
object |
A fitted |
... |
Additional nested fitted models (MLE, same family recommended). |
test |
Which test to report (only |
Value
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
Description
Convert spbp Bayesian fit to posterior draws
Usage
as_draws_df.spbp(x, variables = c("beta", "gamma"), ...)
Arguments
x |
A fitted |
variables |
Character vector of posterior components to include
( |
... |
Not used. |
Value
A posterior::draws_df object on the back-transformed scale.
Augment data with spbp model information
Description
Add fitted values, residuals, and optional survival predictions to the training (or supplied) data.
Usage
## S3 method for class 'spbp'
augment(
x,
data = NULL,
eval_time = NULL,
type = c("martingale", "deviance", "cox-snell", "coxsnell"),
...
)
Arguments
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. |
Value
A data.frame with original rows plus .residual and,
when eval_time is set, a list-column .pred.
Bernstein polynomial baseline specification
Description
Helper for specifying a Bernstein polynomial baseline via the
dist / baseline arguments accepted by spbp.
Usage
bernstein(m = NULL)
Arguments
m |
Bernstein polynomial degree (number of basis coefficients). |
Value
A list with components baseline and m.
Examples
bernstein(5)
Bernstein basis polynomials calculations
Description
Bernstein basis polynomials calculations
Usage
bp.basis(time, degree, tau = max(time))
Arguments
time |
a vector of times. |
degree |
Bernstein polynomial degree |
tau |
must be greater than times maximum value observed. |
Value
A list containing matrices g and G corresponding BP basis and corresponding tau value used to compute them.
Bernstein survival regression specification
Description
Convenience constructor mapping family to the appropriate
parsnip model (proportional_hazards, proportional_odds, or
survival_reg).
Usage
bp_survival_reg(
family = c("ph", "po", "aft"),
mode = "censored regression",
engine = "spsurv"
)
Arguments
family |
Model family: |
mode |
Model mode (default |
engine |
parsnip engine (default |
Value
A parsnip model specification.
Bernstein AFT Model
Description
Fits the BPAFT model to time-to-event data.
Usage
bpaft(
formula,
degree = NULL,
data,
approach = c("mle", "bayes"),
dist = NULL,
baseline = NULL,
...
)
Arguments
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 |
Value
An object of class spbp, including component degree.
See Also
spbp, bpph and bppo for other BP based models.
Examples
library("spsurv")
data("veteran", package = "survival")
fit <- bpaft(Surv(time, status) ~ karno + celltype,
data = veteran
)
summary(fit)
Bernstein PH Model
Description
Fits the BPPH model to time-to-event data.
Usage
bpph(
formula,
degree = NULL,
data,
approach = c("mle", "bayes"),
dist = NULL,
baseline = NULL,
...
)
Arguments
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 |
Value
An object of class spbp, including component degree.
See Also
spbp, bppo and bpaft for other BP based models.
Examples
library("spsurv")
data("veteran", package = "survival")
fit <- bpph(Surv(time, status) ~ karno + factor(celltype),
data = veteran
)
summary(fit)
Bernstein PO Model
Description
Fits the BPPO model to time-to-event data.
Usage
bppo(
formula,
degree = NULL,
data,
approach = c("mle", "bayes"),
dist = NULL,
baseline = NULL,
...
)
Arguments
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 |
Value
An object of class spbp, including component degree.
See Also
spbp, bpph and bpaft for other BP based models.
Examples
library("spsurv")
data("veteran", package = "survival")
fit <- bppo(Surv(time, status) ~ karno + celltype,
data = veteran
)
summary(fit)
Estimated regression coefficients
Description
Estimated regression coefficients
Usage
## S3 method for class 'spbp'
coef(object, summary = c("mean", "median", "mode"), ...)
Arguments
object |
an object of the class spbp |
summary |
posterior summary if method = "bayes" in x |
... |
further arguments passed to or from other methods |
Value
the estimated regression coefficients
Confidence intervals for the regression coefficients
Description
Confidence intervals for the regression coefficients
Usage
## S3 method for class 'spbp'
confint(object, parm, level = 0.95, ...)
Arguments
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 |
Value
100(1-alpha) confidence intervals for the requested parameters.
Generic S3 method credint
Description
Generic S3 method credint
Usage
credint(x, ...)
Arguments
x |
a fitted model object |
... |
further arguments passed to parent method |
Value
Generic function dispatching to credint.spbp.
Credible intervals for the regression coefficients
Description
Credible intervals for the regression coefficients
Usage
## S3 method for class 'spbp'
credint(x, prob = 0.95, type = c("HPD", "Equal-Tailed"), ...)
Arguments
x |
an object of the class x. |
prob |
the probability level required. |
type |
interval type. |
... |
further arguments passed to or from other methods. |
Value
100(1-alpha) credible intervals for the regression coefficients
Parameter estimates for fitted spbp models
Description
Parameter estimates for fitted spbp models
Usage
estimates(object, ...)
Arguments
object |
A fitted |
... |
Not used. |
Value
Named numeric vector of regression and Bernstein-polynomial parameters.
Extract AIC from a fitted spbp model
Description
Extract AIC from a fitted spbp model
Usage
## S3 method for class 'spbp'
extractAIC(fit, scale = 0, k = 2, ...)
Arguments
fit |
A fitted |
scale |
Not used. |
k |
Penalty per parameter (default 2). |
... |
Not used. |
ggplot2 residual diagnostic plots for spbp models
Description
Convenience wrapper around residuals.spbp that returns a
ggplot2 object for martingale, deviance, or Cox-Snell residuals.
Usage
ggresiduals(
object,
type = c("martingale", "deviance", "cox-snell", "coxsnell"),
against = c("fitted", "index"),
...
)
Arguments
object |
A fitted |
type |
Residual type: |
against |
What to plot on the x-axis: |
... |
Further arguments passed to |
Value
A ggplot object (requires ggplot2).
Examples
## 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)
Glance at a fitted spbp model
Description
Return a one-row broom/generics-style summary of model-level statistics.
Usage
## S3 method for class 'spbp'
glance(x, ...)
Arguments
x |
A fitted |
... |
Currently unused. |
Value
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
Description
Log-likelihood for fitted spbp models
Usage
## S3 method for class 'spbp'
logLik(object, ...)
Arguments
object |
A fitted |
... |
Not used. |
Model.matrix method for fitted spbp models
Description
Model.matrix of a fitted spbp model.
Usage
## S3 method for class 'spbp'
model.matrix(object, ...)
Arguments
object |
an object of class 'spbp', see |
... |
arguments passed to parent method. |
Value
The model matrix.
See Also
Examples
library("spsurv")
data("veteran", package = "survival")
fit <- bpph(Surv(time, status) ~ karno + factor(celltype),
data = veteran
)
model.matrix(fit)
BP based models plot.
Description
Plot for a fitted spbp model.
Usage
## S3 method for class 'spbp'
plot(
x,
main,
graph = c("baseline", "basis"),
cumulative = FALSE,
frame = FALSE,
lwd = 3,
...
)
Arguments
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 |
See Also
spbp.
Examples
library("spsurv")
data("veteran", package = "survival")
fit <- bpph(Surv(time, status) ~ karno + factor(celltype),
data = veteran
)
plot(fit)
Predicted survival as a tidy data frame
Description
Survival (and optional CI) on a time grid, as a data.frame for
ggplot2::geom_line.
Usage
## 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,
...
)
Arguments
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 |
Value
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.
See Also
Examples
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
Description
Bernstein Polynomial Based Regression Object Print
Usage
## S3 method for class 'spbp'
print(
x,
bp.param = FALSE,
show_baseline = FALSE,
digits = 2,
signif.stars = getOption("show.signif.stars"),
what = "summary",
...
)
Arguments
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 |
Value
none
Bernstein Polynomial Based Regression Object Summary BPAFT Bayes
Description
Bernstein Polynomial Based Regression Object Summary BPAFT Bayes
Usage
## S3 method for class 'summary.bpaft.bayes'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary BPAFT MLE
Description
Bernstein Polynomial Based Regression Object Summary BPAFT MLE
Usage
## S3 method for class 'summary.bpaft.mle'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary BPPH Bayes
Description
Bernstein Polynomial Based Regression Object Summary BPPH Bayes
Usage
## S3 method for class 'summary.bpph.bayes'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary BPPH MLE
Description
Bernstein Polynomial Based Regression Object Summary BPPH MLE
Usage
## S3 method for class 'summary.bpph.mle'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary BPPO Bayes
Description
Bernstein Polynomial Based Regression Object Summary BPPO Bayes
Usage
## S3 method for class 'summary.bppo.bayes'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object BPPO MLE
Description
Bernstein Polynomial Based Regression Object BPPO MLE
Usage
## S3 method for class 'summary.bppo.mle'
print(...)
Arguments
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary Bayes
Description
Bernstein Polynomial Based Regression Object Summary Bayes
Usage
## S3 method for class 'summary.spbp.bayes'
print(x, digits = 2, signif.stars = getOption("show.signif.stars"), ...)
Arguments
x |
a summary.spbp.bayes object |
digits |
number of digits to display. |
signif.stars |
see |
... |
further arguments passed to or from other methods |
Value
none
Bernstein Polynomial Based Regression Object Summary MLE
Description
Bernstein Polynomial Based Regression Object Summary MLE
Usage
## S3 method for class 'summary.spbp.mle'
print(x, digits = 2, signif.stars = getOption("show.signif.stars"), ...)
Arguments
x |
a summary.spbp.mle object |
digits |
number of digits to display. |
signif.stars |
see |
... |
further arguments passed to or from other methods |
Value
none
Proportional odds regression model specification
Description
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.
Usage
proportional_odds(mode = "censored regression", engine = "spsurv")
Arguments
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. |
Value
A model specification.
Power basis polynomials calculations
Description
Power basis polynomials calculations
Usage
pw.basis(degree)
Arguments
degree |
Bernstein polynomial degree |
Value
A list containing matrices g and G corresponding BP basis and corresponding tau value used to compute them.
Rank fitted spbp models by AIC
Description
Convenience wrapper around AIC that returns models sorted from
lowest to highest AIC.
Usage
rank_models(...)
Arguments
... |
One or more fitted |
Value
A data.frame with columns fit, model,
degree, aic, and npars.
Examples
## 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)
BP based models residuals.
Description
Residuals for a fitted spbp model.
Usage
## S3 method for class 'spbp'
residuals(
object,
type = c("martingale", "deviance", "cox-snell", "coxsnell"),
...
)
Arguments
object |
an object of class 'spbp' result of a |
type |
type of residuals; default is |
... |
arguments passed to parent method. |
See Also
Examples
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
Description
Standard errors for fitted spbp model parameters
Usage
se(object, ...)
Arguments
object |
A fitted |
... |
Not used. |
Value
Named numeric vector of standard errors aligned with estimates.
spbp: The BP Based Survival Analysis Function
Description
Semiparametric Survival Analysis Using Bernstein Polynomial
Usage
spbp(formula, ...)
Arguments
formula |
a |
... |
Arguments passed to |
Details
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.
Value
An object of class "spbp". See spbp.default for
the list of components (coefficients, bp.param,
degree, etc.).
See Also
spbp.default, bpph, bppo,
bpaft, bernstein
Examples
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
Description
spbp: The BP Based Semiparametric Survival Analysis Function
Usage
## 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,
...
)
Arguments
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 |
Details
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, anddegree.
Value
An object of class spbp. Component degree records the
Bernstein polynomial degree used in the fit (also stored in call$degree).
See Also
bpph, bppo, bpaft,
bernstein, summary.spbp
Posterior survival curves in long tidy format
Description
Posterior survival curves in long tidy format
Usage
spread_surv_draws.spbp(object, times, newdata = NULL, ...)
Arguments
object |
A Bayesian |
times |
Numeric vector of evaluation times. |
newdata |
Optional covariate profiles. |
... |
Not used. |
Value
A data.frame with .chain, .iteration, .draw,
time, surv, and optional covariate columns.
Fit proportional hazards model (spsurv parsnip engine)
Description
Fit proportional hazards model (spsurv parsnip engine)
Usage
spsurv_fit_proportional_hazards(formula, data, case_weights = NULL, ...)
Fit proportional odds model (spsurv parsnip engine)
Description
Fit proportional odds model (spsurv parsnip engine)
Usage
spsurv_fit_proportional_odds(formula, data, case_weights = NULL, ...)
Fit AFT model (spsurv parsnip engine)
Description
Fit AFT model (spsurv parsnip engine)
Usage
spsurv_fit_survival_reg(formula, data, case_weights = NULL, ...)
Predict linear predictor (spsurv parsnip engine)
Description
Predict linear predictor (spsurv parsnip engine)
Usage
spsurv_pred_linear_pred(object, new_data, ...)
Predict survival probabilities (spsurv parsnip engine)
Description
Predict survival probabilities (spsurv parsnip engine)
Usage
spsurv_pred_survival(object, new_data, eval_time, ...)
Predict median event time (spsurv parsnip engine)
Description
Predict median event time (spsurv parsnip engine)
Usage
spsurv_pred_time(object, new_data, ...)
Bernstein Polynomial Based Regression Object Summary
Description
Bernstein Polynomial Based Regression Object Summary
Usage
## 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"),
...
)
Arguments
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 |
Value
An object of class analogous to for e.g. 'summary.bppo.bayes'.
BP-based model survival curves
Description
Compute survival curves for a fitted spbp model.
Usage
## 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,
...
)
Arguments
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). |
Value
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.
Functions
-
as.data.frame(survfitbp): Tidy survival curves forggplot2::geom_line/geom_ribbon. -
plot(survfitbp): Plot Bernstein-polynomial survival as a smooth line (type = "l"), never a Kaplan–Meier step function. Passconf.int = TRUEfor pointwise bands (also drawn with lines).
See Also
spbp, survfit,
predict.spbp, survfit.spbp (as.data.frame method).
Examples
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))
Tidy summary for fitted spbp models
Description
Create a broom/generics-style tidy data frame with one row per model term.
Usage
## S3 method for class 'spbp'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
component = c("coef", "baseline", "all"),
...
)
Arguments
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. |
Value
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.
Covariance of the regression coefficients
Description
Uses block-wise inversion of the negative Hessian, with a clear split between the regression coefficients (beta) and the Bernstein polynomial coefficients (gamma).
Usage
## S3 method for class 'spbp'
vcov(object, bp.param = FALSE, mask_unstable_gamma = TRUE, ...)
Arguments
object |
an object of the class spbp |
bp.param |
return Bernstein Polynomial variance. |
mask_unstable_gamma |
when |
... |
arguments passed to parent method. |
Value
the variance-covariance matrix associated with the regression coefficients.