OHDSI / PatientLevelPrediction

An R package for performing patient level prediction in an observational database in the OMOP Common Data Model.
https://ohdsi.github.io/PatientLevelPrediction
188 stars 89 forks source link

Cox model: definition of `timepoint` #299

Open rekkasa opened 2 years ago

rekkasa commented 2 years ago

Describe the bug If timepoint is missing from the definition of the population settings a default timepoint based on riskWindowEnd setting is set (develop branch: CyclopsModels.R, line 256). This assumes that the endAnchor setting was "cohort start". Maybe we should prevent allowing the user to set it to "cohort end" as it requires knowing a future patient's full time at risk to do predictions.

Set up (please run in R "sessionInfo()" and copy the output here): Not needed

To Reproduce Any cox model with timepoint = 0 and endAnchor = "cohort end" will do.

PLP Log File Not needed

Additional context None

jreps commented 2 years ago

Yeah - this was something I realized when writing the code but wasn't sure how to address it. Sometimes people want to predict from the cohort end, but then the timepoint is not possible to set as the time point is relative to cohort start. I wonder whether we can add in extra columns to the cohort where we have the time relative to the cohort end and use these times rather than those relative to the cohort start when people select cohort end? I think this would require adding a bit of SQL when extracting the data and an edit to the population code.