Package 'spsurv'

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

Help Index


The 'spsurv' package.

Description

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.

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.

_PACKAGE

Value

none

Author(s)

[email protected]

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.


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 Polynomial Based Accelerated Failure Time Model

Description

Fits the BPAFT model to time-to-event data.

Usage

bpaft(formula, degree, data, approach = c("mle", "bayes"), ...)

Arguments

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

Value

An object of class 'spbp'.

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 Polynomial Based Proportional Hazards Model

Description

Fits the BPPH model to time-to-event data.

Usage

bpph(formula, degree, data, approach = c("mle", "bayes"), ...)

Arguments

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

Value

An object of class 'spbp'.

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 Polynomial Based Proportional Odds Model

Description

Fits the BPPO model to time-to-event data.

Usage

bppo(formula, degree, data, approach = c("mle", "bayes"), ...)

Arguments

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

Value

An object of class 'spbp'.

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 = names(coef(object)), level = 0.95, ...)

Arguments

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

Value

100(1-alpha) confidence intervals for the regression coefficients


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

the estimated regression coefficients


Confidence intervals for the regression coefficients

Description

Confidence 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) confidence intervals for the regression coefficients


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 spbp.

...

arguments passed to parent method.

Value

The model matrix.

See Also

spbp, model.matrix

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 = F,
  frame = F,
  lwd = 3,
  ...
)

Arguments

x

an object of class 'spbp' result of a spbp fit.

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)

Bernstein Polynomial Based Regression Object Print

Description

Bernstein Polynomial Based Regression Object Print

Usage

## S3 method for class 'spbp'
print(
  x,
  bp.param = FALSE,
  digits = max(getOption("digits") - 4, 3),
  signif.stars = getOption("show.signif.stars"),
  ...
)

Arguments

x

an object of class spbp.

bp.param

print BP parameters.

digits

number of digits to display.

signif.stars

see getOption.

...

further arguments passed to or from other methods.

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 = max(getOption("digits") - 4, 3), ...)

Arguments

x

a summary.spbp.bayes object

digits

number of digits to display.

...

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 = max(getOption("digits") - 4, 3),
  signif.stars = getOption("show.signif.stars"),
  ...
)

Arguments

x

a summary.spbp.mle object

digits

number of digits to display.

signif.stars

see getOption

...

further arguments passed to or from other methods

Value

none


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.


BP based models residuals.

Description

Residuals for a fitted spbp model.

Usage

## S3 method for class 'spbp'
residuals(object, type = c("martingale", "deviance", "coobject-snell"), ...)

Arguments

object

an object of class 'spbp' result of a spbp fit.

type

type of residuals, default is "cox-snell"

...

arguments passed to parent method.

See Also

spbp, spbp.

Examples

library("spsurv")
data("veteran", package = "survival")

fit <- bpph(Surv(time, status) ~ karno + factor(celltype),
  data = veteran
)

residuals(fit)

spbp: The BP Based Survival Analysis Function

Description

Semiparametric Survival Analysis Using Bernstein Polynomial

Usage

spbp(formula, ...)

Arguments

formula

a Surv object with time to event, status and explanatory terms.

...

Arguments passed to 'rstan::sampling' (e.g. iter, chains) or 'rstan::optimizing'.

Details

Fits Bernstein Polynomial based Proportional regression to survival data.

Value

An object of class 'spbp'.

See Also

spbp.default

spbp.default, bpph, bppo, bpaft, https://mc-stan.org/users/documentation/

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,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,
  ...
)

Arguments

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

Value

An object of class spbp


Bernstein Polynomial Based Regression Object Summary

Description

Bernstein Polynomial Based Regression Object Summary

Usage

## S3 method for class 'spbp'
summary(object, interval = 0.95, ...)

Arguments

object

an object of class spbp

interval

interval coverage (confidence or credibility)

...

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,
  times,
  se.fit = TRUE,
  interval = 0.95,
  type = c("log", "log-log", "plain"),
  ...
)

Arguments

formula

An object of class "spbp" returned by spbp.

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 TRUE, compute standard errors.

interval

Confidence level for intervals (e.g. 0.95).

type

Character; confidence interval transformation. One of "log", "log-log", or "plain".

...

Further arguments (currently ignored or reserved for future use).

Value

An object of class "survfit".

See Also

spbp, survfit.

Examples

library(spsurv)
data(veteran, package = "survival")
fit <- bpph(Surv(time, status) ~ karno + factor(celltype), data = veteran)
survfit(fit)

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, ...)

Arguments

object

an object of the class spbp

bp.param

return Bernstein Polynomial variance.

...

arguments passed to parent method.

Value

the variance-covariance matrix associated with the regression coefficients.