Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: R: graphing sensitivity and specificity for a binary test outcome


From   "Carlo Lazzaro" <[email protected]>
To   <[email protected]>
Subject   st: R: graphing sensitivity and specificity for a binary test outcome
Date   Tue, 10 Nov 2009 11:08:12 +0100

Dear Michael,
something like this may help you out?
-----------------------------------------------------
clear
set obs 1000
set seed 12358
gen test=1 + int(2*uniform())
replace test=0 if test==2
replace test=1 in 1/300
gen disease=0 in 1/500
replace disease=1 in 501/1000
list in 1/20
tab test disease, row
gen device=1 + int(2*uniform())
bysort device: tab test disease, row
g sensibility_1 =  test if test==1 & disease==1 & device==1
g sensibility_2 =  test if test==1 & disease==1 & device==2
g specificity_1 =  test if test==0 & disease==0 & device==1
g specificity_2 =  test if test==0 & disease==0 & device==2
replace  specificity_1=1 if  specificity_1==0
replace specificity_2=1 if  specificity_2==0
g sensibility_1_pc= sensibility_1/249
g sensibility_2_pc= sensibility_2/251
g specificity_1_pc= sensibility_1/258
g specificity_2_pc=  specificity_2/242
graph hbar (sum) sensibility_1_pc sensibility_2_pc specificity_1_pc
specificity_2_pc
--------------------------------------------------------------------

Kind Regards,
Carlo
-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Michael McCulloch
Inviato: martedì 10 novembre 2009 7.04
A: Statalist Statalist
Oggetto: st: graphing sensitivity and specificity for a binary test outcome

Dear Statalist members,

With the following code I simulate diagnostic data and, in the last  
line, estimate specificity (cell A in the 2x2 table) and sensitivity  
(cell D).
What I'm hoping to learn is how to create a bar graph that would  
display the specificity and sensitivity percentages for both methods 1  
and 2.

***
clear
set obs 1000	
set seed 12358	
gen test=1 + int(2*uniform())	
replace test=0 if test==2
replace test=1 in 1/300		
gen disease=0 in 1/500
replace disease=1 in 501/1000
list in 1/20
tab test disease, row
gen device=1 + int(2*uniform())	
bysort device: tab test disease, row
***




Michael McCulloch
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391
[email protected]






*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index