hesim-dev / hesim

Health economic simulation modeling and decision analysis
https://hesim-dev.github.io/hesim/
62 stars 16 forks source link

PSM simulation samples return total probability more than 1 #56

Closed Hazwang closed 3 years ago

Hazwang commented 3 years ago

Hi. I'm super excited on each new update. I would like to ask whether there is a way to replace/ exclude/ substitute the samples with more than 1 total probability?

# Sim state prob
psm$sim_stateprobs()

# get samples more than 1 tot probability
surv_cross <- psm$stateprobs_
surv_cross[, sum:=sum(prob), 
           by=.(sample, strategy_id, patient_id, grp_id, t)][sum>1]
dincerti commented 3 years ago

Hi,

Glad you are finding the package helpful! I'm guessing this is occurring when survival curves are crossing. Solutions in these cases are definitely worth revisiting --- I'll take a closer look and ensure this doesn't happen.

-Devin

dincerti commented 3 years ago

Hi @Hazwang I have reworked the way in which hesim deals with situations where curves cross. The most recent development version should now ensure that probabilities will always sum to 1. Text explaining how crossing survival curves are handled is now provided in the sim_stateprobs.survival() function. Let me know if you run into any additional problems.

Thanks for flagging this!

-Devin

Hazwang commented 3 years ago

Hi Devin,

Thank you for your swift response. I look forward to trying it out.

-Hazwan-