Learn R Programming

spsurv (version 1.1.0)

survfit.spbp: BP-based model survival curves

Description

Compute survival curves for a fitted spbp model.

Usage

# S3 method for 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 survfitbp as.data.frame(x, row.names = NULL, optional = FALSE, ...)

# S3 method for survfitbp plot( x, conf.int, col = 1, lty = 1, lwd = 1.5, xlab = "Time", ylab = "Survival probability", ylim = c(0, 1), mark.time = FALSE, ... )

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.

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 evaluation times: a Surv object (legacy), or a non-negative numeric vector (unique values are used; suitable for smooth ggplot2::geom_line plots via predict.spbp or as.data.frame.survfitbp).

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

interval.type

For Bayesian fits only: "hpd" (default) or "quantile" (equal-tailed).

monotone

Logical; for Bayesian fits, enforce non-increasing credible-band limits over time so ribbons plot smoothly with ggplot2::geom_line. Defaults to TRUE when approach = "bayes".

tidy

Logical; if TRUE, return a data.frame for ggplot2. instead of a "survfit" object.

baseline

Logical; if TRUE, return the baseline survival curve \(S_0(t)\) at observed event times (or times) with no covariate effect. When tidy = TRUE, returns a simple data.frame with columns time and surv.

...

Further arguments passed to survfit.coxph for the reference Cox object (e.g. conf.type is ignored; use type instead).

x

Object from survfit.spbp.

row.names, optional

Unused; included for S3 consistency.

conf.int

Logical; draw pointwise interval limits. Defaults to TRUE for a single curve when limits are present.

col, lty, lwd, xlab, ylab, ylim

Graphical parameters.

mark.time

Ignored (Bernstein curves are continuous).

Functions

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

See Also

spbp, survfit, predict.spbp, survfit.spbp (as.data.frame method).

Examples

Run this code
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))

Run the code above in your browser using DataLab