Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forest_model doesn't show interactions in Cox PH models #29

Open
Generalized opened this issue Sep 29, 2020 · 1 comment
Open

forest_model doesn't show interactions in Cox PH models #29

Generalized opened this issue Sep 29, 2020 · 1 comment

Comments

@Generalized
Copy link

Dear Authors,
I noticed, that the forest_model function doesn't plot interactions. The version from CRAN doesn't do that, so I downloaded and installed the most fresh code from the GitHub. Same result. Is this by design to show only the main effects?

Expected behavior

Interaction effects should be shown

Actual behavior

Only the main effects are shown

Steps to reproduce the problem

Fit any Cox model with an interaction.
Run forest_model ()on it.

> forest_model( fit <- coxph(Surv(time, status) ~ ph.karno * age, data=lung))
Resized limits to included dashed line in forest panel
> summary(fit, conf.int = FALSE)
Call:
coxph(formula = Surv(time, status) ~ ph.karno * age, data = lung)

  n= 227, number of events= 164 
   (1 observation deleted due to missingness)

                   coef  exp(coef)   se(coef)      z Pr(>|z|)  
ph.karno     -0.1211782  0.8858761  0.0486092 -2.493   0.0127 *
age          -0.1206758  0.8863212  0.0610426 -1.977   0.0481 *
ph.karno:age  0.0016586  1.0016600  0.0007525  2.204   0.0275 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Concordance= 0.598  (se = 0.025 )
Likelihood ratio test= 14.52  on 3 df,   p=0.002
Wald test            = 13.42  on 3 df,   p=0.004
Score (logrank) test = 13.44  on 3 df,   p=0.004

obraz

session_info()

- Session info ---------------------------------------------------------------
 setting  value                       
 version  R version 4.0.2 (2020-06-22)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       Rgui                        
 language (EN)                        
 date     2020-09-29                  

- Packages -------------------------------------------------------------------
 package     * version   date       lib source                               
 abind         1.4-5     2016-07-21 [1] CRAN (R 4.0.0)                       
 assertthat    0.2.1     2019-03-21 [1] CRAN (R 4.0.2)                       
 backports     1.1.10    2020-09-15 [1] CRAN (R 4.0.2)                       
 broom         0.7.0     2020-07-09 [1] CRAN (R 4.0.2)                       
 callr         3.4.4     2020-09-07 [1] CRAN (R 4.0.2)                       
 car           3.0-9     2020-08-11 [1] CRAN (R 4.0.2)                       
 carData       3.0-4     2020-05-22 [1] CRAN (R 4.0.0)                       
 cellranger    1.1.0     2016-07-27 [1] CRAN (R 4.0.2)                       
 cli           2.0.2     2020-02-28 [1] CRAN (R 4.0.2)                       
 colorspace    1.4-1     2019-03-18 [1] CRAN (R 4.0.2)                       
 cowplot       1.1.0     2020-09-08 [1] CRAN (R 4.0.2)                       
 crayon        1.3.4     2017-09-16 [1] CRAN (R 4.0.2)                       
 curl          4.3       2019-12-02 [1] CRAN (R 4.0.2)                       
 data.table    1.13.0    2020-07-24 [1] CRAN (R 4.0.2)                       
 desc          1.2.0     2018-05-01 [1] CRAN (R 4.0.2)                       
 devtools      2.3.2     2020-09-18 [1] CRAN (R 4.0.2)                       
 digest        0.6.25    2020-02-23 [1] CRAN (R 4.0.2)                       
 dplyr         1.0.2     2020-08-18 [1] CRAN (R 4.0.2)                       
 ellipsis      0.3.1     2020-05-15 [1] CRAN (R 4.0.2)                       
 fansi         0.4.1     2020-01-08 [1] CRAN (R 4.0.2)                       
 farver        2.0.3     2020-01-16 [1] CRAN (R 4.0.2)                       
 forcats       0.5.0     2020-03-01 [1] CRAN (R 4.0.2)                       
 foreign       0.8-80    2020-05-24 [1] CRAN (R 4.0.2)                       
 forestmodel * 0.6.2     2020-09-29 [1] Github (NikNakk/forestmodel@dd8eb55) 
 fs            1.5.0     2020-07-31 [1] CRAN (R 4.0.2)                       
 generics      0.0.2     2018-11-29 [1] CRAN (R 4.0.2)                       
 ggplot2     * 3.3.2     2020-06-19 [1] CRAN (R 4.0.2)                       
 ggpubr      * 0.4.0     2020-06-27 [1] CRAN (R 4.0.2)                       
 ggsignif      0.6.0     2019-08-08 [1] CRAN (R 4.0.2)                       
 glue          1.4.2     2020-08-27 [1] CRAN (R 4.0.2)                       
 gridExtra     2.3       2017-09-09 [1] CRAN (R 4.0.2)                       
 gtable        0.3.0     2019-03-25 [1] CRAN (R 4.0.2)                       
 haven         2.3.1     2020-06-01 [1] CRAN (R 4.0.2)                       
 hms           0.5.3     2020-01-08 [1] CRAN (R 4.0.2)                       
 km.ci         0.5-2     2009-08-30 [1] CRAN (R 4.0.2)                       
 KMsurv        0.1-5     2012-12-03 [1] CRAN (R 4.0.0)                       
 knitr         1.30      2020-09-22 [1] CRAN (R 4.0.2)                       
 labeling      0.3       2014-08-23 [1] CRAN (R 4.0.0)                       
 lattice       0.20-41   2020-04-02 [1] CRAN (R 4.0.2)                       
 lifecycle     0.2.0     2020-03-06 [1] CRAN (R 4.0.2)                       
 magrittr      1.5       2014-11-22 [1] CRAN (R 4.0.2)                       
 Matrix        1.2-18    2019-11-27 [1] CRAN (R 4.0.2)                       
 memoise       1.1.0     2017-04-21 [1] CRAN (R 4.0.2)                       
 munsell       0.5.0     2018-06-12 [1] CRAN (R 4.0.2)                       
 openxlsx      4.2.2     2020-09-17 [1] CRAN (R 4.0.2)                       
 pillar        1.4.6     2020-07-10 [1] CRAN (R 4.0.2)                       
 pkgbuild      1.1.0     2020-07-13 [1] CRAN (R 4.0.2)                       
 pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 4.0.2)                       
 pkgload       1.1.0     2020-05-29 [1] CRAN (R 4.0.2)                       
 prettyunits   1.1.1     2020-01-24 [1] CRAN (R 4.0.2)                       
 processx      3.4.4     2020-09-03 [1] CRAN (R 4.0.2)                       
 ps            1.3.4     2020-08-11 [1] CRAN (R 4.0.2)                       
 purrr         0.3.4     2020-04-17 [1] CRAN (R 4.0.2)                       
 R6            2.4.1     2019-11-12 [1] CRAN (R 4.0.2)                       
 Rcpp          1.0.5     2020-07-06 [1] CRAN (R 4.0.2)                       
 readxl        1.3.1     2019-03-13 [1] CRAN (R 4.0.2)                       
 remotes       2.2.0     2020-07-21 [1] CRAN (R 4.0.2)                       
 rio           0.5.16    2018-11-26 [1] CRAN (R 4.0.2)                       
 rlang         0.4.7     2020-07-09 [1] CRAN (R 4.0.2)                       
 rprojroot     1.3-2     2018-01-03 [1] CRAN (R 4.0.2)                       
 rstatix       0.6.0     2020-06-18 [1] CRAN (R 4.0.2)                       
 scales        1.1.1     2020-05-11 [1] CRAN (R 4.0.2)                       
 sessioninfo   1.1.1     2018-11-05 [1] CRAN (R 4.0.2)                       
 stringi       1.5.3     2020-09-09 [1] CRAN (R 4.0.2)                       
 stringr       1.4.0     2019-02-10 [1] CRAN (R 4.0.2)                       
 survival    * 3.2-3     2020-06-13 [1] CRAN (R 4.0.2)                       
 survminer   * 0.4.8.999 2020-09-29 [1] Github (kassambara/survminer@acff36f)
 survMisc      0.5.5     2018-07-05 [1] CRAN (R 4.0.2)                       
 testthat      2.3.2     2020-03-02 [1] CRAN (R 4.0.2)                       
 tibble        3.0.3     2020-07-10 [1] CRAN (R 4.0.2)                       
 tidyr         1.1.2     2020-08-27 [1] CRAN (R 4.0.2)                       
 tidyselect    1.1.0     2020-05-11 [1] CRAN (R 4.0.2)                       
 usethis       1.6.3     2020-09-17 [1] CRAN (R 4.0.2)                       
 vctrs         0.3.4     2020-08-29 [1] CRAN (R 4.0.2)                       
 withr         2.3.0     2020-09-22 [1] CRAN (R 4.0.2)                       
 xfun          0.17      2020-09-09 [1] CRAN (R 4.0.2)                       
 xtable        1.8-4     2019-04-21 [1] CRAN (R 4.0.2)                       
 zip           2.1.1     2020-08-27 [1] CRAN (R 4.0.2)                       
 zoo           1.8-8     2020-05-02 [1] CRAN (R 4.0.2)                       

[1] C:/tmp/r4/library
> 
@ShixiangWang
Copy link
Contributor

I checked the source code, and it seems not easy to do this.

In current stage, I suggest you obtain the coef values from model and generate segment plot with ggplot2 or other graphic package directly.

To obtain coefs, you can use:

broom::tidy(model, conf.int = TRUE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants