Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vaccination Markov Model - issue with initial cost #345

Closed
zaddyzad opened this issue Nov 17, 2020 · 9 comments
Closed

Vaccination Markov Model - issue with initial cost #345

zaddyzad opened this issue Nov 17, 2020 · 9 comments

Comments

@zaddyzad
Copy link

I'm running a simple time-homogeneous Markov model. It's unclear why the final cost of drugs is $3,960 rather than $4,000. The cost of vaccination is $4 and the initial state count for A == 1,000 (i.e., healthy children). Could this be a bug?

My abridged code is below:

`dr=0.03

#Transition
vacc=define_transition(
  .97995,.00005,0,.02,
  0,.97,.01,.02,
  0,0,.9,.1,
  0,0,0,1)

#Healthy
state_A <- define_state(
  cost_health = discount(15, dr),
  cost_drugs = discount(dispatch_strategy(
    vaccination = ifelse(model_time == 1, 4, 0),
    no_vaccination = 0), dr),
  cost_total = cost_health + cost_drugs,
  QALY = discount(1,dr)
)

#running the model
res_mod <- run_model(
  vaccination = strat_vacc,
  no_vaccination = strat_no_vacc,
  cycles = 80,
  cost = cost_total,
  effect = QALY
);summary(res_mod)

Initial state counts:

A = 1000L
B = 0L
C = 0L
D = 0L

Counting method: 'life-table'.

Values:

               cost_health cost_drugs cost_total     QALY
vaccination       304360.2       3960   308320.2 20011.43
no_vaccination    316803.2          0   316803.2 20005.90
@KZARCA
Copy link
Collaborator

KZARCA commented Nov 17, 2020

Hi,
I cannot reproduce your error as I do not have your full code. If you need help, please send it to me.
Best,
Kevin

@zaddyzad
Copy link
Author

Hi,
I cannot reproduce your error as I do not have your full code. If you need help, please send it to me.
Best,
Kevin

Hi Kevin, thanks for the help, the full code is here

dr=0.03

#Transition
vacc=define_transition(
  .97995,.00005,0,.02,
  0,.97,.01,.02,
  0,0,.9,.1,
  0,0,0,1)

no.vacc=define_transition(
  .9798,.0002,0,.02,
  0,.97,.01,.02,
  0,0,.9,.1,
  0,0,0,1)

#Healthy
state_A <- define_state(
  cost_health = discount(15, dr),
  cost_drugs = discount(dispatch_strategy(
    vaccination = ifelse(model_time == 1, 4, 0),
    no_vaccination = 0), dr),
  cost_total = cost_health + cost_drugs,
  QALY = discount(1,dr)
)

#chronic HBV
state_B <- define_state(
  cost_health = discount(15, dr),
  cost_drugs = discount(dispatch_strategy(
    vaccination = ifelse(model_time == 1, 4, 0),
    no_vaccination = cost_no_vaccination), dr),
  cost_total = cost_health + cost_drugs,
  QALY = discount(1,dr)
)

#compensated cirrhosis 
state_C <- define_state(
  cost_health = discount(3500, dr),
  cost_drugs = discount(dispatch_strategy(
    vaccination = ifelse(model_time == 1, 4, 0),
    no_vaccination = cost_no_vaccination), dr),
  cost_total = cost_health + cost_drugs,
  QALY = discount(0.75,dr)
)

#dead 
state_D <- define_state(
  cost_health = 0,
  cost_drugs = 0,
  cost_total = 0,
  QALY = 0
)

#defining strategies
strat_vacc <- define_strategy(
  transition = vacc,
  state_A,
  state_B,
  state_C,
  state_D
)

#defining strategies
strat_no_vacc <- define_strategy(
  transition = no.vacc,
  state_A,
  state_B,
  state_C,
  state_D
)

#running the model
res_mod <- run_model(
  vaccination = strat_vacc,
  no_vaccination = strat_no_vacc,
  cycles = 80,
  cost = cost_total,
  effect = QALY
);summary(res_mod)

@KZARCA
Copy link
Collaborator

KZARCA commented Nov 17, 2020

It's not a bug, heemod uses a first-cycle correction named "life-table" by default. You can read more on https://journals.sagepub.com/doi/10.1177/0272989X09340585

If you want the transition to occur at the beginning of the cycle, you can choose method = "beginning".
Best

@zaddyzad
Copy link
Author

It's not a bug, heemod uses a first-cycle correction named "life-table" by default. You can read more on https://journals.sagepub.com/doi/10.1177/0272989X09340585

If you want the transition to occur at the beginning of the cycle, you can choose method = "beginning".
Best

'beginning' and 'end' may be inversed in heemod. Per the article 'beginning' should yield an overestimate and 'end' should yield an underestimate.

This is not reflected in the model.

Counting method: 'beginning'.

Values:

               cost_health cost_drugs cost_total     QALY
vaccination       301399.5       3920   305319.5 19809.24
no_vaccination    314056.4          0   314056.4 19803.60

Counting method: 'end'.

Values:

               cost_health cost_drugs cost_total     QALY
vaccination       307320.9       4000   311320.9 20213.62
no_vaccination    319550.0          0   319550.0 20208.21

@KZARCA
Copy link
Collaborator

KZARCA commented Nov 17, 2020

OK thanks for your input, I will change it in the next heemod version.
Best

@zaddyzad
Copy link
Author

OK thanks for your input, I will change it in the next heemod version.
Best

Thank you.

@zaddyzad
Copy link
Author

@KZARCA, I am facing another issue with the run_dsa function. It works well when I define only 1 sensitivity analyses to be done (i.e., cost_vacc, discount_rate [dr]); however, when I define multipe, I get the following error:

Running DSA on strategy 'vaccination'...
Error: Can't subset columns that don't exist.
x Columns care_cirrohosis, dr, and rr don't exist.

Code is below:

library(heemod)
library(tidyverse)
dr=0.03
cost_vacc=4
care_cirrohosis=3500
rr=0.25

#Transition
vacc=define_transition(
  C,0.0002*rr,0,.02,
  0,.97,.01,.02,
  0,0,.9,.1,
  0,0,0,1)

no.vacc=define_transition(
  .9798,.0002,0,.02,
  0,.97,.01,.02,
  0,0,.9,.1,
  0,0,0,1)

#Healthy
state_A <- define_state(
  cost_health = discount(15, dr),
  cost_drugs = dispatch_strategy(
    vaccination = ifelse(model_time == 1, cost_vacc, 0),
    no_vaccination = 0),
  cost_total = cost_health + cost_drugs,
  QALY = discount(1,dr)
)

#chronic HBV
state_B <- define_state(
  cost_health = discount(15, dr),
  cost_drugs = dispatch_strategy(
    vaccination = ifelse(model_time == 1, cost_vacc, 0),
    no_vaccination = 0),
  cost_total = cost_health + cost_drugs,
  QALY = discount(1,dr)
)

#compensated cirrhosis 
state_C <- define_state(
  cost_health = discount(care_cirrohosis, dr),
  cost_drugs = dispatch_strategy(
    vaccination = ifelse(model_time == 1, cost_vacc, 0),
    no_vaccination = 0),
  cost_total = cost_health + cost_drugs,
  QALY = discount(0.75,dr)
)

#dead 
state_D <- define_state(
  cost_health = 0,
  cost_drugs = 0,
  cost_total = 0,
  QALY = 0
)

#defining strategies
strat_vacc <- define_strategy(
  transition = vacc,
  state_A,
  state_B,
  state_C,
  state_D
)

#defining strategies
strat_no_vacc <- define_strategy(
  transition = no.vacc,
  state_A,
  state_B,
  state_C,
  state_D
)

#running the model
res_mod <- run_model(
  vaccination = strat_vacc,
  no_vaccination = strat_no_vacc,
  cycles = 80,
  init=c(1000000,0,0,0),
  cost = cost_total,
  effect = QALY,
  method='end'
);summary(res_mod)

##plot
plot(res_mod, type = "counts", panel = "by_strategy") +
  xlab("Time") +
  theme_bw() +
  scale_color_brewer(
    name = "State",
    palette = "Set1"
  )

##sensitivity analyses and tornado plot
ds=define_dsa(
    cost_vacc, 2, 30,
    care_cirrohosis,1000,5000,
    dr, 0.015, 0.06,
    rr, 0.3,0.5
 )

print(ds)

x=run_dsa(res_mod,ds)
plot(x,type='difference',result='icer')

`
```

@KZARCA
Copy link
Collaborator

KZARCA commented Nov 26, 2020

Hi, all your variables should be encapsulated within the function define_parameters

params <- define_parameters(
dr=0.03,
cost_vacc=4,
care_cirrohosis=3500,
rr=0.25
)

@KZARCA KZARCA closed this as completed Nov 26, 2020
@minakabiri
Copy link

Hi There. I am using heemod for a simulation and I realized that the update related to this issue has changed the results. I checked (by looking at the counts -numebr of people in each state- in each cycle) and realized that the update has changed the package such that with the "beginning" method, transitions happen at the end of the cycle, and with the "end" method, transitions happened at the beginning of the cycle. I think this is probably incorrect though. Maybe there is an error in calculating costs and effects related to the method chosen, but the counts were correct, and now incorrect with this update.

Thanks for your consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants