PharmD Info

A forum for Indian Pharmacy Professionals

Research funding schemes, UGC Approved Journals, Project Protocols, Clinical Study Designs, Clinical Trails Registry and Regulation, Biostatistics Forum.
Forum rules: General rules are applicable for this forum- Find Here
  • User avatar
  • User avatar
#5470
CEA (Cost-Effectiveness Analysis) is a type of economic evaluation that compares the costs and health outcomes of different interventions or treatments. In this program, we will conduct a CEA analysis using a model case scenario and a relevant dataset.

For this analysis, we will use the following dataset:

Intervention | Cost | Effectiveness
------------------------------------
Intervention1 | 100 | 0.8
Intervention2 | 150 | 0.9
Intervention3 | 200 | 1.0
Intervention4 | 250 | 1.1
Intervention5 | 300 | 1.2

The dataset contains information about the costs and effectiveness of five different interventions. We will assume that the effectiveness is measured on a scale from 0 to 1, where 1 represents perfect health.

To conduct the CEA analysis, we will follow these steps:

  • Calculate the incremental cost-effectiveness ratio (ICER) for each intervention compared to the next best alternative.
  • Create a cost-effectiveness plane to visualize the results of the analysis.
  • Calculate the net monetary benefit (NMB) for each intervention and plot a cost-effectiveness acceptability curve (CEAC) to determine the probability of each intervention being cost-effective at different willingness-to-pay (WTP) thresholds.

Here is the Python code to conduct the CEA analysis:
Code: Select all
import numpy as np
import matplotlib.pyplot as plt

# Define the dataset
interventions = ['Intervention1', 'Intervention2', 'Intervention3', 'Intervention4', 'Intervention5']
costs = [100, 150, 200, 250, 300]
effects = [0.8, 0.9, 1.0, 1.1, 1.2]

# Calculate the incremental cost-effectiveness ratio (ICER)
ICERs = []
for i in range(len(interventions)-1):
    ICER = (costs[i+1] - costs[i]) / (effects[i+1] - effects[i])
    ICERs.append(ICER)

# Create a cost-effectiveness plane
plt.scatter(effects, costs)
plt.xlabel('Effectiveness')
plt.ylabel('Cost')
plt.title('Cost-Effectiveness Plane')
for i in range(len(interventions)):
    plt.annotate(interventions[i], (effects[i], costs[i]))

# Calculate the net monetary benefit (NMB)
WTP = np.linspace(0, 1000, 101)
NMBs = []
for i in range(len(interventions)):
    NMB = effects[i] * WTP - costs[i]
    NMBs.append(NMB)

# Plot the cost-effectiveness acceptability curve (CEAC)
CEAC = []
for wtp in WTP:
    num = sum([1 for i in range(len(interventions)) if NMBs[i] >= wtp])
    prob = num / len(interventions)
    CEAC.append(prob)

plt.figure()
plt.plot(WTP, CEAC)
plt.xlabel('Willingness-to-Pay')
plt.ylabel('Probability of Cost-Effectiveness')
plt.title('Cost-Effectiveness Acceptability Curve')

In this code, we first define the dataset as three lists: “interventions”, “costs”, and “effects”. We then calculate the ICER for each intervention compared to the next best alternative and store the results in the "ICERs" list.

Next, we create a scatter plot of the cost-effectiveness plane using "plt.scatter()". We label each point with the name of the corresponding intervention using "plt.annotate()".

We then calculate the NMB for each intervention at different WTP thresholds using "np.linspace()" to create a range of WTP values and a 'for" loop to calculate the NMB for each intervention at each WTP value. We store the results in the "NMBs" list.

Finally, we plot the CEAC using "plt.plot()". We calculate the probability of each intervention being cost-effective at each WTP threshold using a "for" loop and the "sum()" function to count the number of interventions with an NMB greater than or equal to the WTP threshold. We then divide this count by the total number of interventions to get the probability of cost-effectiveness.

The output of the program will be a cost-effectiveness plane and a cost-effectiveness acceptability curve, which can be used to make decisions about which intervention is most cost-effective based on the available data and the decision-maker's willingness-to-pay.


Here is the complete Python code with comments to explain each step:
Code: Select all
import numpy as np
import matplotlib.pyplot as plt

# Define the dataset
interventions = ['Intervention1', 'Intervention2', 'Intervention3', 'Intervention4', 'Intervention5']
costs = [100, 150, 200, 250, 300]
effects = [0.8, 0.9, 1.0, 1.1, 1.2]

# Calculate the incremental cost-effectiveness ratio (ICER)
ICERs = []
for i in range(len(interventions)-1):
    ICER = (costs[i+1] - costs[i]) / (effects[i+1] - effects[i])
    ICERs.append(ICER)

# Create a cost-effectiveness plane
plt.scatter(effects, costs)
plt.xlabel('Effectiveness')
plt.ylabel('Cost')
plt.title('Cost-Effectiveness Plane')
for i in range(len(interventions)):
    plt.annotate(interventions[i], (effects[i], costs[i]))

# Calculate the net monetary benefit (NMB)
WTP = np.linspace(0, 1000, 101)
NMBs = []
for i in range(len(interventions)):
    NMB = effects[i] * WTP - costs[i]
    NMBs.append(NMB)

# Plot the cost-effectiveness acceptability curve (CEAC)
CEAC = []
for wtp in WTP:
    num = sum([1 for i in range(len(interventions)) if NMBs[i] >= wtp])
    prob = num / len(interventions)
    CEAC.append(prob)

plt.figure()
plt.plot(WTP, CEAC)
plt.xlabel('Willingness-to-Pay')
plt.ylabel('Probability of Cost-Effectiveness')
plt.title('Cost-Effectiveness Acceptability Curve')

# Show the plots
plt.show()

This code should produce two plots: a cost-effectiveness plane and a cost-effectiveness acceptability curve.

The cost-effectiveness plane shows the costs and effectiveness of each intervention, with the name of each intervention labeled on the plot. The cost-effectiveness acceptability curve shows the probability of each intervention being cost-effective at different WTP thresholds.

These plots can be used to make decisions about which intervention is most cost-effective based on the available data and the decision-maker's willingness-to-pay. For example, if the decision-maker is willing to pay $200 per unit of effectiveness, the cost-effectiveness acceptability curve shows that there is a high probability that Intervention2 is cost-effective, and a lower probability that Intervention3 or Intervention4 are cost-effective. However, if the decision-maker is willing to pay $500 per unit of effectiveness, the cost-effectiveness acceptability curve shows that there is a high probability that Intervention4 is cost-effective, and a lower probability that any of the other interventions are cost-effective.
#5967
Thanks for the post.

Replying the code appears and error:
Code: Select all
# Plot the cost-effectiveness acceptability curve (CEAC) CEAC = [] for wtp in WTP: num = sum([1 for i in range(len(interventions)) if NMBs[i] >= wtp]) prob = num / len(interventions) CEAC.append(prob) ---------------------------------------------------------------------------ValueError                                Traceback (most recent call last)~\AppData\Local\Temp\ipykernel_28316\1184681348.py in <module>      2 CEAC = []      3 for wtp in WTP:----> 4     num = sum([1 for i in range(len(interventions)) if NMBs[i] >= wtp])      5     prob = num / len(interventions)      6     CEAC.append(prob)~\AppData\Local\Temp\ipykernel_28316\1184681348.py in <listcomp>(.0)      2 CEAC = []      3 for wtp in WTP:----> 4     num = sum([1 for i in range(len(interventions)) if NMBs[i] >= wtp])      5     prob = num / len(interventions)      6     CEAC.append(prob) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Any idea of solution?
#5970
It seems like the issue is with the line if NMBs >= wtp, where NMBs is likely an array. You can use any() or all() to handle the truth value of the array. Try changing that line to something like:
Code: Select all
num = sum([1 for i in range(len(interventions)) if any(NMBs[i] >= wtp)])
 
This should resolve the ambiguity in the truth value of the array.

Need a plagiarism Checker which provides plagiaris[…]

Relay Therapeutics is a biotechnology company that[…]

In recent developments regarding the Graduate Phar[…]

In recent years, the field of pharmacy has undergo[…]

PharmD Info - Highlights