rms
rms copied to clipboard
bug in the `ordESS()` function
Hello,
I am working with the ordESS() function and running into some unexpected behavior.
I am seeing the same message output regardless of whether the model fitted with orm() that is passed to the ordESS() function includes the y=TRUE and lpe=TRUE arguments. Here is the code I ran along with the outputs I see:
library(rms)
resect <- read.csv("./man/resect.csv")
orm_output <- orm(died ~ resection, data = resect)
ordESS(orm_output)
orm_output_args <- orm(died ~ resection, data = resect, y = TRUE, lpe = TRUE)
ordESS(orm_output_args)
Looking at the source code, I think it's a problem with the implemented logic here: https://github.com/harrelfe/rms/blob/7c4f42b3852ee11419bf8e2e8576a2b8499362d2/R/ordESS.r#L20C6-L21C26
So, I ran the following code using the objects created in the above code chunk:
'y' %nin% names(orm_output) || 'lpe' %nin% names(orm_output) || ! length(orm_output$Ncens1) || sum(orm_output$Ncens1) == 0
'y' %nin% names(orm_output)
'lpe' %nin% names(orm_output)
! length(orm_output$Ncens1)
sum(orm_output$Ncens1) == 0
'y' %nin% names(orm_output_args) || 'lpe' %nin% names(orm_output_args) || ! length(orm_output_args$Ncens1) || sum(orm_output_args$Ncens1) == 0
'y' %nin% names(orm_output_args)
'lpe' %nin% names(orm_output_args)
! length(orm_output_args$Ncens1)
sum(orm_output_args$Ncens1) == 0
And this is what I see:
Two questions here:
- Would it make more sense to just use
%in%instead ofHmisc's%nin%? - What is the purpose of checking the last two bits of the logic statement, where (i.e.,
! length(orm_output_args$Ncens1)andsum(orm_output_args$Ncens1) == 0)?
Thanks so much for your time on this!
Arianna C.
> sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
Running under: Rocky Linux 9.3 (Blue Onyx)
Matrix products: default
BLAS: /opt/R/openval/rc_20250900/4.5.0/lib64/R/lib/libRblas.so
LAPACK: FlexiBLAS OPENBLAS-OPENMP; LAPACK version 3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rms_8.0-0 Hmisc_5.2-3
loaded via a namespace (and not attached):
[1] sandwich_3.1-1 generics_0.1.4 stringi_1.8.7 lattice_0.22-7 digest_0.6.37 magrittr_2.0.3 evaluate_1.0.3 grid_4.5.0
[9] RColorBrewer_1.1-3 mvtnorm_1.3-3 fastmap_1.2.0 Matrix_1.7-3 nnet_7.3-20 backports_1.5.0 Formula_1.2-5 survival_3.8-3
[17] multcomp_1.4-28 gridExtra_2.3 scales_1.4.0 TH.data_1.1-3 codetools_0.2-20 cli_3.6.5 rlang_1.1.6 splines_4.5.0
[25] base64enc_0.1-3 tools_4.5.0 MatrixModels_0.5-4 SparseM_1.84-2 checkmate_2.3.2 htmlTable_2.4.3 dplyr_1.1.4 colorspace_2.1-1
[33] ggplot2_3.5.2 vctrs_0.6.5 R6_2.6.1 rpart_4.1.24 zoo_1.8-14 polspline_1.1.25 lifecycle_1.0.4 stringr_1.5.1
[41] htmlwidgets_1.6.4 MASS_7.3-65 foreign_0.8-90 cluster_2.1.8.1 pkgconfig_2.0.3 pillar_1.10.2 gtable_0.3.6 rsconnect_1.4.0
[49] glue_1.8.0 data.table_1.17.2 xfun_0.52 tibble_3.2.1 tidyselect_1.2.1 rstudioapi_0.17.1 knitr_1.50 dichromat_2.0-0.1
[57] farver_2.1.2 nlme_3.1-168 htmltools_0.5.8.1 rmarkdown_2.29 compiler_4.5.0 quantreg_6.1