Learn R Programming

butcher (version 0.3.5)

axe-survreg: Axing an survreg.

Description

survreg objects are created from the survival package. They are returned from the survreg function, representing fitted parametric survival models.

Usage

# S3 method for survreg
axe_call(x, verbose = FALSE, ...)

# S3 method for survreg axe_data(x, verbose = FALSE, ...)

# S3 method for survreg axe_env(x, verbose = FALSE, ...)

Value

Axed survreg object.

Arguments

x

A model object.

verbose

Print information each time an axe method is executed. Notes how much memory is released and what functions are disabled. Default is FALSE.

...

Any additional arguments related to axing.

Examples

Run this code
# Load libraries
library(parsnip)
library(survival)

# Create model and fit
survreg_fit <- surv_reg(mode = "regression", dist = "weibull") %>%
  set_engine("survival") %>%
  fit(Surv(futime, fustat) ~ 1, data = ovarian)

out <- butcher(survreg_fit, verbose = TRUE)

# Another survreg object
wrapped_survreg <- function() {
  some_junk_in_environment <- runif(1e6)
  fit <- survreg(Surv(time, status) ~ ph.ecog + age + strata(sex),
                 data = lung)
  return(fit)
}

# Remove junk
cleaned_survreg <- butcher(wrapped_survreg(), verbose = TRUE)

# Check size
lobstr::obj_size(cleaned_survreg)

Run the code above in your browser using DataLab