Closed EarlGlynn closed 2 years ago
Hi, that shouldn't happen – do you have a reproducible example for me to double-check?
The comorbidity()
functions runs some checks before returning results to make sure that only values of 0 and 1 are present in the output, so this is surprising!
This example code uses all the ICD10 codes for depression, and returns the expected results:
library(comorbidity)
comorbidity(
x = data.frame(
id = 1,
code = c("F204", "F313", "F314", "F315", "F32", "F33", "F341", "F412", "F432")),
id = "id",
code = "code",
map = "elixhauser_icd10_quan",
assign0 = FALSE
)
#> id chf carit valv pcd pvd hypunc hypc para ond cpd diabunc diabc hypothy rf
#> 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> ld pud aids lymph metacanc solidtum rheumd coag obes wloss fed blane dane
#> 1 0 0 0 0 0 0 0 0 0 0 0 0 0
#> alcohol drug psycho depre
#> 1 0 0 1 1
Created on 2022-02-07 by the reprex package (v2.0.1)
Could you try running this and let me know if this works as expected? In the meanwhile, could you try restarting your R session from a clean state? Maybe something stuck from upgrading the package is causing a clash.
Edit: I forgot to mention – nothing significant has changed with the depr
mapping that hasn't changed with the others, so if there's a bug, it would (should?) equally affect all conditions.
Thank you for your quick reply. Your code worked fine for me. The mistake was mine.
This was totally my mistake -- so sorry for the false alarm. I had 4000+ patients with either ICD 9 or ICD 10 codes, or both. So, I found their comorbidities separately, and made a mistake in the function passed to purrr
that combined the ICD 9 and/or ICD 10 results for a given patient. I was creating a new column with the number of comorbidities, and with the score
column missing, I mistakenly assigned that to the depre
column. I like your change once I studied what you were doing, since we only wanted the comorbidities (based on both ICD 9 and 10) but had concluded there was a no good way to create a combined score. With the correct code, I have the same results for both old and new versions of the package.
No worries, and happy to hear it works now, yielding the same results. This is very valuable feedback!
Having separate "comorbidity" and "scores" logics was one of the main changes of this version, as we can now much more easily add extra scores or algorithms. Glad to hear you like this change! 😃
After upgrading from version 0.5.3 to 1.0.0 I'm seeing different results for processing 4000+ patients, but only for the
depr
condition when using map = "elixhauser_icd9_quan" or map = "elixhauser_icd10_quan". Did something change in how you're assigning adepr
condition based on ICD 9 or ICD 10 codes?Instead of only 0 and 1 values to indicate a comorbidity for
depr
, I'm also seeing values 2, 3, 4, 5, 6, 7, and 9 -- there were no 8s. Why is the comorbidity mapping fordepr
different from all others?Here's how I'm calling the
comorbidty
function: