Filter ezcox

filter_ezcox(x, levels = "auto", type = c("both", "contrast", "ref"))

Arguments

x

a ezcox object from ezcox().

levels

levels to filter, default is 'auto', it will filter all control variables.

type

default is 'both' for filtering both contrast level and reference level. It can also be 'contrast' for filtering only contrast level and 'ref' for filtering only reference level.

Value

a ezcox object

Author

Shixiang Wang w_shixiang@163.com

Examples

library(survival)
lung$ph.ecog <- factor(lung$ph.ecog)
zz <- ezcox(lung, covariates = c("sex", "age"), controls = "ph.ecog")
#> => Processing variable sex
#> ==> Building Surv object...
#> ==> Building Cox model...
#> ==> Done.
#> => Processing variable age
#> ==> Building Surv object...
#> ==> Building Cox model...
#> ==> Done.
zz
#> # A tibble: 8 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.545   0.58   0.417   0.806
#> 2 sex      TRUE      1       0           113    63  0.418   1.52   1.03    2.25 
#> 3 sex      TRUE      2       0            50    63  0.947   2.58   1.66    4.01 
#> 4 sex      TRUE      3       0             1    63  2.05    7.76   1.04   58    
#> 5 age      FALSE     age     age         228   228  0.0108  1.01   0.992   1.03 
#> 6 age      TRUE      1       0           113    63  0.359   1.43   0.969   2.11 
#> 7 age      TRUE      2       0            50    63  0.857   2.36   1.5     3.7  
#> 8 age      TRUE      3       0             1    63  2.11    8.23   1.09   61.8  
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95
filter_ezcox(zz)
#> # A tibble: 2 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.545   0.58   0.417   0.806
#> 2 age      FALSE     age     age         228   228  0.0108  1.01   0.992   1.03 
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95
filter_ezcox(zz, c("0", "2"))
#> Filtering control levels in 'both' mode:
#> 	0, 2
#> # A tibble: 2 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.545   0.58   0.417   0.806
#> 2 age      FALSE     age     age         228   228  0.0108  1.01   0.992   1.03 
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95
filter_ezcox(zz, c("0", "2"), type = "contrast")
#> Filtering control levels in 'contrast' mode:
#> 	0, 2
#> # A tibble: 6 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.545   0.58   0.417   0.806
#> 2 sex      TRUE      1       0           113    63  0.418   1.52   1.03    2.25 
#> 3 sex      TRUE      3       0             1    63  2.05    7.76   1.04   58    
#> 4 age      FALSE     age     age         228   228  0.0108  1.01   0.992   1.03 
#> 5 age      TRUE      1       0           113    63  0.359   1.43   0.969   2.11 
#> 6 age      TRUE      3       0             1    63  2.11    8.23   1.09   61.8  
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95
t <- filter_ezcox(zz, c("0", "2"), type = "ref")
#> Filtering control levels in 'ref' mode:
#> 	0, 2
t
#> # A tibble: 2 × 12
#>   Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref    beta    HR lower…⁵ upper…⁶
#>   <chr>    <lgl>     <chr>   <chr>     <dbl> <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1 sex      FALSE     sex     sex         228   228 -0.545   0.58   0.417   0.806
#> 2 age      FALSE     age     age         228   228  0.0108  1.01   0.992   1.03 
#> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
#> #   variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
#> #   ⁵​lower_95, ⁶​upper_95