Giter VIP home page Giter VIP logo

Comments (9)

KZARCA avatar KZARCA commented on June 20, 2024

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

from heemod.

zaddyzad avatar zaddyzad commented on June 20, 2024

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)

from heemod.

KZARCA avatar KZARCA commented on June 20, 2024

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

from heemod.

zaddyzad avatar zaddyzad commented on June 20, 2024

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

from heemod.

KZARCA avatar KZARCA commented on June 20, 2024

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

from heemod.

zaddyzad avatar zaddyzad commented on June 20, 2024

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

Thank you.

from heemod.

zaddyzad avatar zaddyzad commented on June 20, 2024

@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')

`
```

from heemod.

KZARCA avatar KZARCA commented on June 20, 2024

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
)

from heemod.

minakabiri avatar minakabiri commented on June 20, 2024

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.

from heemod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.