OHDSI / CohortDiagnostics

An R package for performing various cohort diagnostics.
https://ohdsi.github.io/CohortDiagnostics
40 stars 45 forks source link

[BUG] cohort incidence may report incidence rate = infinity #1062

Open gowthamrao opened 1 year ago

gowthamrao commented 1 year ago

I observed values of 'Inf' in the output file. This should not happen. Its happening when a persons denominator start_date = end_date make denominator = 0

https://github.com/OHDSI/CohortDiagnostics/blob/ea6b5f8994cf2b493aa4c6c534397ffe8808ac8e/inst/sql/sql_server/ComputeIncidenceRates.sql#L47

I think we should add where clause to remove records that are contributing 0 to the denominator? Plus, if the start_date - end_date then they probably cannot contribute to rate

azimov commented 10 months ago

I agree that the result returned should never be inf but the datediff function should always return a number and the rate is fixed to 365.25. 0/365 = 0 - which is 0 - not undefined so this is a really result weird. The only way this ratio can result in Inf is if the DATEDIFF is Inf - which i can believe happens on some platforms if one of the dates is null maybe?

Is this on redshift or another platform?

gowthamrao commented 10 months ago

redshift