Skip to content

Axing a coxph.

Usage

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

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

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.

Value

Axed coxph object.

Examples

library(survival)

example_data <-
  tibble::tibble(
    time = rpois(1000, 2) + 1,
    status = rbinom(1000, 1, .5),
    x = rpois(1000, .5),
    covar = rbinom(1000, 1, .5)
  )

example_data
#> # A tibble: 1,000 × 4
#>     time status     x covar
#>    <dbl>  <int> <int> <int>
#>  1     4      0     5     1
#>  2     2      1     0     1
#>  3     2      0     0     0
#>  4     3      0     0     0
#>  5     1      0     0     1
#>  6     4      1     1     0
#>  7     3      1     0     1
#>  8     1      1     1     0
#>  9     5      0     0     0
#> 10     3      1     0     1
#> # … with 990 more rows

make_big_model <- function() {
  boop <- runif(1e6)
  coxph(Surv(time, status) ~ x + strata(covar), example_data)
}

res <- make_big_model()

weigh(res)
#> # A tibble: 20 × 2
#>    object                    size
#>    <chr>                    <dbl>
#>  1 terms                 8.15    
#>  2 formula               8.15    
#>  3 residuals             0.0722  
#>  4 y                     0.0177  
#>  5 linear.predictors     0.00805 
#>  6 call                  0.00146 
#>  7 concordance           0.000752
#>  8 coefficients          0.00028 
#>  9 means                 0.00028 
#> 10 wald.test             0.00028 
#> 11 var                   0.000224
#> 12 xlevels.strata(covar) 0.000176
#> 13 method                0.000112
#> 14 loglik                0.000064
#> 15 score                 0.000056
#> 16 iter                  0.000056
#> 17 n                     0.000056
#> 18 nevent                0.000056
#> 19 assign.x              0.000056
#> 20 timefix               0.000056
weigh(butcher(res))
#> # A tibble: 20 × 2
#>    object                    size
#>    <chr>                    <dbl>
#>  1 terms                 8.15    
#>  2 residuals             0.0722  
#>  3 linear.predictors     0.00805 
#>  4 formula               0.00149 
#>  5 call                  0.00146 
#>  6 concordance           0.000752
#>  7 coefficients          0.00028 
#>  8 means                 0.00028 
#>  9 wald.test             0.00028 
#> 10 var                   0.000224
#> 11 xlevels.strata(covar) 0.000176
#> 12 method                0.000112
#> 13 loglik                0.000064
#> 14 score                 0.000056
#> 15 iter                  0.000056
#> 16 n                     0.000056
#> 17 nevent                0.000056
#> 18 assign.x              0.000056
#> 19 timefix               0.000056
#> 20 y                     0.000048