Hi everyone,
I have spent the weekend browsing this excellent forum and the web for a solution to my problem, but unfortunately without succeding. Any help would be very much appreciated.
In STATA 16.1, I have a dataset of 18 patients of whom 8 have viable disease, and we are testing a biomarker. 4 tests are positive, and three of those are true positives. The data is added below, the varible PADRPLND is viable disease and the variable POSMIR is a positive marker.
I have done performance calculations to obtain sensitivity, specificity, PPV and NPV, either by the diagt-command, or by logistic regression and then estat classification.
I now need to add the bootstrap by a 1000 reps to obtain the 95% CI and the standard error, for these four calculations.
The main problem seems to be that I can't store the previous estimates for the bootstrap procedure to use. I have then tried to write a program for the calculations to loop in the bootstrap, and seem to have success with the sens and spec but not the PPV and NPV.
I also need an upper bound so that the CI don't surpass 100% in any of the calculations.
Thank you for your help and I hope this is somewhat clear, since it's my first post.
by this, STATA replies "last estimates not found".
Also if I use,
I only get dots which I think means that the estimates are not stored.
The other way I tried was by using this code I found in the forum;
These are the results
Problem here is that the upper interval of spec exceeds 100%.
If anyone could please help me expand the code for PPV and NPV, my problem would be solved. Thank you!
I have spent the weekend browsing this excellent forum and the web for a solution to my problem, but unfortunately without succeding. Any help would be very much appreciated.
In STATA 16.1, I have a dataset of 18 patients of whom 8 have viable disease, and we are testing a biomarker. 4 tests are positive, and three of those are true positives. The data is added below, the varible PADRPLND is viable disease and the variable POSMIR is a positive marker.
I have done performance calculations to obtain sensitivity, specificity, PPV and NPV, either by the diagt-command, or by logistic regression and then estat classification.
I now need to add the bootstrap by a 1000 reps to obtain the 95% CI and the standard error, for these four calculations.
The main problem seems to be that I can't store the previous estimates for the bootstrap procedure to use. I have then tried to write a program for the calculations to loop in the bootstrap, and seem to have success with the sens and spec but not the PPV and NPV.
I also need an upper bound so that the CI don't surpass 100% in any of the calculations.
Thank you for your help and I hope this is somewhat clear, since it's my first post.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int Id byte(PADRPLND POSMIR)
7019 0 0
7020 1 0
7036 0 0
7038 0 0
7056 0 1
7067 0 0
7071 0 0
7074 1 0
7075 0 0
7078 1 0
7081 0 0
7084 0 0
7506 1 1
7507 1 1
2045 1 0
2057 1 1
2220 0 0
2236 1 0
end
logit PADRPLND POSMIR
estat classification
scalar sensitivity = r(Sensitivity)
scalar specificity = r(Specificity)
scalar ppv = r(Positive predictive value)
scalar npv = r(Negative predictive value)
// Bootstrap sensitivity
bootstrap, reps(1000) seed(12345):
// Calculate sensitivity
r(sensitivity) = sens_est
// Bootstrap specificity
bootstrap, reps(1000) seed(12345):
// Calculate specificity
r(specificity) = spec_est
// Bootstrap PPV
bootstrap, reps(1000) seed(12345):
// Calculate PPV
r(ppv) = ppv_est
// Bootstrap NPV
bootstrap, reps(1000) seed(12345):
// Calculate NPV
r(npv) = npv_est
Also if I use,
Code:
di "Sensitivity: " sensitivity di "Specificity: " specificity di "PPV: " ppv di "NPV: " npv
The other way I tried was by using this code I found in the forum;
Code:
capture program drop operating_characteristics
program define operating_characteristics, rclass
summ POSMIR if PADRPLND, meanonly
local sensitivity = r(mean)
summ POSMIR if !PADRPLND, meanonly
local specificity = 1 - r(mean)
return scalar sensitivity = `sensitivity'
return scalar specificity = `specificity'
return scalar likelihood_ratio = `sensitivity'/(1-`specificity')
exit
end
bootstrap sens = r(sensitivity) spec = r(specificity) lr = r(likelihood_ratio), ///
reps(500): operating_characteristics
Code:
Bootstrap results Number of obs = 18
Replications = 325
command: operating_characteristics
sens: r(sensitivity)
spec: r(specificity)
lr: r(likelihood_ratio)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sens | .375 .1804689 2.08 0.038 .0212874 .7287126
spec | .9 .075812 11.87 0.000 .7514113 1.048589
lr | 3.75 2.094575 1.79 0.073 -.3552913 7.855291
------------------------------------------------------------------------------
Note: One or more parameters could not be estimated in 175 bootstrap
replicates; standard-error estimates include only complete replications.
If anyone could please help me expand the code for PPV and NPV, my problem would be solved. Thank you!

Comment