rdecisionDecision tree construction and visualization
Model evaluation: substitute the Roll-Back for calculating expected values
ICER calculation
Decision trees are widely used in economic evaluation, including cost-effectiveness analysis and cost-utility analysis within the field of Health Economics.
A decision tree represents clinical pathways using nodes and branches. The main components include:
Decision node Represents a choice between interventions.
Chance node Represents uncertain events with associated probabilities.
Terminal node Represents final health outcomes.
Costs and utilities Each pathway accumulates costs and health outcomes.
The decision tree model incorporates three main categories of parameters: clinical probabilities, costs, and health outcomes. These parameters determine the likelihood of each pathway in the decision tree and the economic and clinical consequences associated with each terminal node.
Scenario description:
We’re comparing two treatments for Acute Respiratory Infection:
Treatment A: More expensive, more effective, higher ADR risk
Treatment B: Less expensive, less effective, lower ADR risk
Each treatment has 4 possible pathways:
No ADR + Cured
No ADR + Not Cured
ADR + Cured
ADR + Not Cured
The decision tree model captures these potential clinical pathways and associates each branch with probabilities, costs, and outcomes.
The decision tree model calculates the expected costs and effectiveness of each treatment strategy by aggregating the outcomes across all possible clinical pathways.
For each treatment option, the probability of reaching a particular terminal node is determined by multiplying the probabilities along the branches leading to that node.
Each terminal node is associated with a specific cost and health outcome reflecting the clinical pathway followed by the patient.
The expected cost of a treatment strategy is calculated as the weighted sum of the costs of all terminal nodes, where the weights correspond to the probability of each pathway occurring.
Similarly, the expected effectiveness is calculated as the weighted sum of the effectiveness values associated with the terminal nodes.
The expected costs and effectiveness of each treatment strategy are then compared to estimate the incremental cost-effectiveness ratio, defined as: ICER =(C_1-C_0)/(E_1-E_0 )
where C_1and C_0represent the expected costs of the two treatment alternatives, and E_1and E_0 represent their corresponding health outcomes. This framework allows for the systematic evaluation of competing treatment strategies within the decision tree structure.
Installing and Loading the Package
Defining Model Nodes
Defining Actions and Reactions
Constructing the Decision Tree
Evaluating Expected Costs and Outcomes
Calculating the ICER
#==========================
# Acute Respiratory Infection Decision Tree CE Model
#==========================
#--------------------------
# 1. Load package
#--------------------------
library(rdecision)
library(dplyr) # For pipe operator
library(flextable)
Decision Tree Model Structure
A decision tree model can be represented mathematically as a directed graph consisting of nodes and branches.
In graph-theoretic terms, the nodes correspond to the vertices (V) and the branches correspond to the edges (E) that connect these vertices. The combination of vertices and edges forms the structural framework of the decision model.
Decision nodes represent alternative interventions or strategies under evaluation. These nodes define the competing options available to the decision maker.
Chance nodes represent uncertain events that may occur following a decision. Each branch emerging from a chance node is associated with a probability that reflects the likelihood of that outcome.
Terminal nodes (or leaf nodes) represent the final outcomes of the decision process, where costs and health outcomes such as utilities or quality-adjusted life years are assigned.
Branches represent the pathways that connect nodes and represent the sequence of events occurring within the model. In this framework, branches are represented by two types of objects: actions and reactions.
Actions represent the primary pathways that originate from a decision node and correspond to the alternative interventions being compared, while reactions represent the possible consequences that occur following an action. These typically correspond to transitions from chance nodes to subsequent chance nodes or terminal nodes and are associated with probabilities and, where relevant, costs or health outcomes.
Together, nodes and branches constitute the fundamental building blocks required for constructing a decision tree model.
Create Nodes or Vertices (V)
# 2. NODES (V)
#---------------------
# (1) Decision Node
#---------------------
decision <- DecisionNode$new("ARI")
#---------------------
# (2) Chance Nodes
#---------------------
c_trtA <- ChanceNode$new("Treatment_A")
c_no_adr_A <- ChanceNode$new("no_adverse_reaction")
c_adr_A <- ChanceNode$new("adverse_reaction")
c_trtB <- ChanceNode$new("Treatment_B")
c_no_adr_B <- ChanceNode$new("no_adverse_reaction")
c_adr_b <- ChanceNode$new("adverse_reaction")
#---------------------
# (3) Terminel or leaf nodes
#---------------------
t1 <- LeafNode$new("Cure_A")
t2 <- LeafNode$new("NotCure_A")
t3 <- LeafNode$new("Cure_A")
t4 <- LeafNode$new("NotCure_A")
t5 <- LeafNode$new("Cure_B")
t6 <- LeafNode$new("NotCure_B")
t7 <- LeafNode$new("Cure_B")
t8 <- LeafNode$new("NotCure_B")
V = list(decision, c_trtA, c_trtB, c_adr_A,c_adr_b,c_no_adr_A,c_no_adr_B,
t1,t2,t3,t4,t5,t6,t7,t8)
Create Edges or branches
Table A. Parameters of a decision model
| Category | Parameter | Value |
|---|---|---|
| Probabilities | Treatment A | |
| Adverse reaction | 0.2 | |
| No Adverse reaction | 0.8 | |
| Cured | 0.9 | |
| Not cured | 0.1 | |
| Treatment B | ||
| Adverse reaction | 0.3 | |
| No Adverse reaction | 0.7 | |
| Cured | 0.8 | |
| Not cured | 0.2 | |
| Costs | Treatment A | $100 |
| Treatment B | $80 | |
| Adverse reaction | $500 | |
| Not cured -- Additional treatment | $150 | |
| Life Years | Cured (Years) | 20 |
| Not cured (Years) | 10 |
Edges include actions and reactions, the alternative treatment options are defined in actions and the consequent pathways in reactions
Create “Actions” and “Reactions” Alternative treatments and associated pathways
# Treatment A or Treatment B
a1<-Action$new(decision, c_trtA, "TRT_A", cost = 100)
a2<-Action$new(decision, c_trtB, "TRT_B", cost = 80)
# Treatment A pathway
r1<-Reaction$new(c_trtA, c_adr_A, p = 0.2) # Trt_A > ADR
r2<-Reaction$new(c_trtA, c_no_adr_A, p = 0.8) # Trt_A > no_ADR
r3<-Reaction$new(c_adr_A, t1, p = 0.9, cost =500, benefit = 20) # ADR & Cured
r4<-Reaction$new(c_adr_A, t2, p = 0.1,cost =650, benefit = 10) # ADR & Not Cured
r5<-Reaction$new(c_no_adr_A, t3, p = 0.9, benefit = 20)
r6<-Reaction$new(c_no_adr_A, t4, p = 0.1, cost = 150, benefit = 10)
# Treatment B pathway
r7<-Reaction$new(c_trtB, c_adr_b, p = 0.3) # Trt_B > ADR
r8<-Reaction$new(c_trtB, c_no_adr_B, p = 0.7) # Trt_B > No_ADR
r9<-Reaction$new(c_adr_b, t5, p = 0.8,cost =500, benefit = 20)
r10<-Reaction$new(c_adr_b,t6, p = 0.2,cost =650, benefit = 10)
r11<-Reaction$new(c_no_adr_B, t7, p = 0.8, benefit = 20)
r12<-Reaction$new(c_no_adr_B, t8, p = 0.2, cost=150, benefit = 10)
E= list(a1,a2,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12)
After defining nodes and branches, the decision tree can be constructed.
Assemble Nodes (vertices) with branches (edges)
tree <- DecisionTree$new(V = V,E = E)
draw()tree$draw()
evaluate()tree$evaluate()
## Run ARI Probability Cost Benefit Utility QALY
## 1 1 TRT_A 1 215 19 1 1
## 2 1 TRT_B 1 260 18 1 1
Output in a table Format
results<-tree$evaluate()
results %>% select(ARI, Cost, Benefit) %>% flextable()
ARI | Cost | Benefit |
|---|---|---|
TRT_A | 215 | 19 |
TRT_B | 260 | 18 |
From the table, Treatment A is dominant compared to treatment B (lower in cost and it is more effective as well). ICER falls in the southeast quadrant on the cost-effectiveness plane.
IC <- results$Cost[1] - results$Cost[2]
IE <- results$Benefit[1]-results$Benefit[2]
ICER<- IC/IE
ICER
## [1] -45
cat("Incremental cost:", IC,"$","\n")
## Incremental cost: -45 $
cat("Incremental benefit:",IE,"\n")
## Incremental benefit: 1
cat("ICER:", ICER, "$","Per life year gained")
## ICER: -45 $ Per life year gained
This tutorial is replicated from the work cited below for the purpose
of showing the capabilities of rdecisionpackage
Original Author: Mark Bounthavong https://rpubs.com/mbounthavong/decision_tree_model_tutorial
YouTube by: Mirko von Hein https://www.youtube.com/watch?v=nZyHJJbIosM&list=UULFCWndUzziarMjA4pDG1ps2A&index=1