砍掉一個coxph。
用法
# S3 method for coxph
axe_env(x, verbose = FALSE, ...)
# S3 method for coxph
axe_data(x, verbose = FALSE, ...)
細節
survival::coxph()
模型的獨特之處在於它在組件中使用環境的方式,並且在除 global environment 之外的任何環境中(例如當包裝在函數中時),屠宰這樣的對象可能會以令人驚訝的方式表現。我們不建議您在全局環境以外的任何地方將 butcher()
與 coxph
對象一起使用。
做這個:
my_coxph_func <- function(df) {
coxph(Surv(time, status) ~ x + strata(covar), df)
}
## in global environment only:
butcher(my_coxph_func(df))
不要這樣做:
my_coxph_func <- function(df) {
res <- coxph(Surv(time, status) ~ x + strata(covar), df)
## no:
butcher(res)
}
## will not work correctly:
my_coxph_func(df)
例子
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
#> # ℹ 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.09
#> 2 formula 8.09
#> 3 y 0.0177
#> 4 residuals 0.00948
#> 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.09
#> 2 residuals 0.00948
#> 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
相關用法
- R butcher axe-flexsurvreg 砍掉一個flexsurvreg。
- R butcher axe-ranger 砍掉一名護林員。
- R butcher axe-ipred 砍倒一棵裝袋的樹。
- R butcher axe-train.recipe 砍掉一個 train.recipe 對象。
- R butcher axe-terms 取消術語輸入。
- R butcher axe-survreg 砍掉一個 survreg。
- R butcher axe-mda 砍掉 mda。
- R butcher axe-earth 砍伐地球物體。
- R butcher axe-spark 砍掉一個Spark物體。
- R butcher axe-gausspr 砍掉高斯。
- R butcher axe-survreg.penal 取消監管處罰
- R butcher axe-glmnet 砍掉 glmnet。
- R butcher axe-rpart 砍掉一個零件。
- R butcher axe-nnet 砍掉一個網絡。
- R butcher axe-formula 取消公式。
- R butcher axe-kknn 砍掉 kknn。
- R butcher axe-bart 砍掉巴特模型。
- R butcher axe-sclass 砍掉一個 sclass 對象。
- R butcher axe-model_fit 取消 model_fit。
- R butcher axe-recipe 砍掉一個配方對象。
- R butcher axe-randomForest 砍掉隨機森林。
- R butcher axe-multnet 砍掉多網。
- R butcher axe-gam 砍掉一個遊戲。
- R butcher axe-mass 砍掉 MASS 判別分析對象。
- R butcher axe-lm 砍掉一部電影。
注:本文由純淨天空篩選整理自Davis Vaughan等大神的英文原創作品 Axing a coxph.。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。