Hi, I have a dataset containing 50 pairs of incremental costs and incremental QALYs, along with their variances and covariances. I am going to graph the Cost-Effectiveness Acceptability Envelope (CEAE) using the following structure:
clear
set more off
* Define the range of thresholds (TH values)
local min_th = 0
local max_th = 100000
local step = 1000
* Create a new dataset to store probabilities at each TH
tempfile ceae_results
save `ceae_results', emptyok
* Loop over threshold values
forvalues th = `min_th'( `step' )`max_th' {
use your_original_dataset, clear
* Compute Net Benefit and its variance for each of the 50 sets
gen NB = `th'*iqaly - icost
gen varNB = (`th')^2 * varq + varc - 2*`th'*cov
* Get mean and variance components
egen meanNB = mean(NB)
egen W_NB = mean(varNB)
gen _Bdiff_NB = (NB - meanNB)^2
egen _Bsum_NB = total(_Bdiff_NB)
gen B_NB = (1/(50-1))*_Bsum_NB
gen T_NB = W_NB + (1 + (1/50))*B_NB
gen seT_NB = sqrt(T_NB)
* Calculate z-score and probability
gen z = meanNB / seT_NB
gen prob = normal(z)
* Store TH and prob in a new dataset
gen th = `th'
keep th prob
keep in 1 // only one row per TH needed
append using `ceae_results'
save `ceae_results', replace
}
Thank you
- I have 50 sets of results Using each set of results, I calculate the following 2 numbers. Then I should have 100 numbers.
- gen NB=iqaly-TH*icost
- gen varNB= TH^2 * varq + varc – 2*TH*cov
- Using those 100 numbers, I calculate the probability of intervention to be cost effective for each one TH value. The code is as the following:
- egen meanNB=mean(NB)
- egen W_NB=mean(varNB)
- gen _Bdiff_NB=(NB-meanNB)^2
- egen _Bsum_NB=total(_Bdiff_NB)
- gen B_NB=(1/(50-1))*_Bsum_NB
- gen T_NB=W_NB+(1+(1/50))*B_NB
- gen seT_NB=sqrt(T_NB)
- local z = meanNB/seT_NB
- local prob = normal(`z')
clear
set more off
* Define the range of thresholds (TH values)
local min_th = 0
local max_th = 100000
local step = 1000
* Create a new dataset to store probabilities at each TH
tempfile ceae_results
save `ceae_results', emptyok
* Loop over threshold values
forvalues th = `min_th'( `step' )`max_th' {
use your_original_dataset, clear
* Compute Net Benefit and its variance for each of the 50 sets
gen NB = `th'*iqaly - icost
gen varNB = (`th')^2 * varq + varc - 2*`th'*cov
* Get mean and variance components
egen meanNB = mean(NB)
egen W_NB = mean(varNB)
gen _Bdiff_NB = (NB - meanNB)^2
egen _Bsum_NB = total(_Bdiff_NB)
gen B_NB = (1/(50-1))*_Bsum_NB
gen T_NB = W_NB + (1 + (1/50))*B_NB
gen seT_NB = sqrt(T_NB)
* Calculate z-score and probability
gen z = meanNB / seT_NB
gen prob = normal(z)
* Store TH and prob in a new dataset
gen th = `th'
keep th prob
keep in 1 // only one row per TH needed
append using `ceae_results'
save `ceae_results', replace
}
Thank you
Comment