Skip to content

rvpanaro/spsurv

Repository files navigation

spsurv

CRAN status CRAN downloads CRAN downloadsR-CMD-check Codecov test coverage

spsurv provides flexible semi-parametric survival regression for right-censored data: proportional hazards (PH), proportional odds (PO), and accelerated failure time (AFT) models with smooth baseline functions estimated via Bernstein polynomials.

Key features

  • PH / PO / AFT regression with Bernstein polynomial baseline functions
  • Estimation via maximum likelihood or Bayesian inference
  • Bayesian fitting via Stan (NUTS/HMC), with multiple prior options
  • Extensible interface for user-defined modeling workflows

Installation

From CRAN

  • Install the CRAN version:
install.packages("spsurv")

Development version

  • Installation using the devtools package:
install.packages("remotes")
remotes::install_github("rvpanaro/spsurv")

Quick start

library(survival)
library(KMsurv)
library(spsurv)

data("larynx")  # time = follow-up time, delta = event indicator

fit <- spbp(Surv(time, delta) ~ age + factor(stage), model = "ph", data = larynx)
summary(fit)  

Bayesian example

set.seed(1)

fit_bayes <- spbp(
  Surv(time, delta) ~ age + factor(stage),
  model = "ph",
  approach = "bayes",
  data = larynx,
  iter = 2000,
  warmup = 1000,
  chains = 4
)

summary(fit_bayes)

More examples: https://rvpanaro.github.io/spsurv/reference/index.html

Citation

citation("spsurv")

Getting help / reporting bugs

Packages

 
 
 

Contributors