hesim-dev / hesim

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

Starting in different states of the model to begin with #10

Closed aheff closed 4 years ago

aheff commented 4 years ago

Hi (again - apologies for the inundation of comments!):

Is there a way in the cohort modelling side of hesim to specify that in one strategy, the cohort starts in one state and in a second strategy the cohort starts in the other? I am comparing a cohort of patients starting on dialysis and a cohort starting on liver transplants.

I see that you can specify which state the model starts in directly by setting start_stateprobs = c(...) in create_CohortDtstm - but this sets the starting state to be the same for all strategies simulated.

I've managed to kind of do this with a hack (see below), but it isn't ideal and I thought either there may be a neater solution or else it could be something useful for future development if you are so inclined.

A second question on the below code: you'll see I've adapted your time-dependent drugs cost code to try and crowbar in a one-off cost of transplant. But when I look at final costs - the drug cost is much higher than the upper bound estimate of my drug cost - and since the cost of transplant should only be added once per simulation I can't figure out why I appear to be adding in more than one transplant cost - even though it should only execute when time == 0?

`tparams_def <- define_tparams({

ntx_switch <- ifelse(strategy_name == "Transplant only" & time < 1e-2, 0.85, 0) # 0.85 chosen as highest value to shift people across from dialysis to transplant (ntx) without sending state occupancy negative

list( tpmatrix = tpmatrix( C, ntx_switch, 0, p_rec_noecu, p_dial_death, # transitions from dialysis (never had recurrence) p_norec_dial, C, p_rec_noecu, 0, p_ntx_death, # transitions from ntx + no-recurrence 0, 0, C, p_rec_dial, p_ntx_death, # transitions from ntx + recurrence 0, 0, 0, C, p_dial_death, # transitions from dialysis post ntx with graft loss with recurrence or else direct recurrence from dialysis 0, 0, 0, 0, 1 # death category - don't edit ), utility = u, costs = list(

add a transplant cost in first cycle

  drug = ifelse(strategy_name == "Transplant only" & time == 0,
                c_transplant, 0),
  # community_medical = c_cmed,
  direct_medical = c_dmed
)

) }, times = c(0,4*49))`

dincerti commented 4 years ago

Currently starting states must be the same across treatment strategies and patients. This would not be hard to modify, so its something I'll consider in future versions.

As for your example, can you send the full code so I can run it?