Skip to content

LK010 — horizon_violation

Outcome occurrences beyond the declared horizon.

default severity error
injector ehrlint.inject.inject_lk010

Why this matters

A two-year task whose outcome window actually reaches five years is a five-year task reported as two. Every metric is then describing a different question from the one the paper states, and the model will underperform when deployed against the stated horizon.

What it looks like in practice

A positive label from an outcome three years after the index date in a two-year task -- usually a label query with no upper bound on time.

The query it runs

SELECT * FROM events e JOIN index_dates i USING (subject_id)
WHERE e.code IN outcome_codes
  AND DATEDIFF('day', i.index_date, e.time) > 730.5
  AND e.subject_id NOT IN (subjects with an in-window occurrence)

Worked example

On the clean synthetic cohort, which is clean by construction:

$ ehrlint audit --data clean/ --task task.yaml --checks LK010

LK010 did not fire.
  Every outcome occurrence falls within the declared 2y horizon.
exit code 0

With the matching leak planted by ehrlint.inject.inject_lk010:

$ ehrlint audit --data leaky/ --task task.yaml --checks LK010

LK010 horizon_violation  [error]
  4 subject(s) have their only outcome occurrence beyond the declared 2y horizon. If they are labelled positive, the task's real horizon is longer than stated.
  affected: 4 of 120 subject(s) (3.3%), 4 row(s)

  example rows:
    subject_id  time                      code    index_date                days_after_index  
    S000006     2021-12-23 13:41:14.4824  E11.65  2019-08-20 06:30:23.8090  856.2991898148148 
    S000060     2020-08-02 20:25:46.7543  E11.65  2018-02-04 12:36:52.2483  910.325625        
    S000065     2023-07-31 04:07:33.7064  E11.65  2020-07-07 14:03:43.4688  1118.5859953703703

exit code 1

Reproduce both:

ehrlint synth --out clean/ --n-subjects 120 --seed 0
ehrlint synth --out leaky/ --n-subjects 120 --seed 0 --inject LK010
ehrlint audit --data leaky/ --task leaky/task.yaml \
  --labels leaky/labels.parquet --splits leaky/splits.json --checks LK010

What to do about it

Bound the outcome query by the horizon, and recount the positives afterwards. The prevalence will drop; that drop was always the truth.

When it skips

A skip is not a pass. This check reports a skip, with the reason, when its inputs are not available — see reading a report.