cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

How do I display multiple ROC curves on the same graph?

Hello everyone,
I am trying to develop a test to distinguish between two groups (0 and 1). There are two tests A and B have different ROC curves which I have been able to plot individually. However I want to generate a graph that displays the ROC curves for A, B and A*B in the same panel. Can anyone help me with this?
2 ACCEPTED SOLUTIONS

Accepted Solutions
mpb
mpb
Level VII

Re: How do I display multiple ROC curves on the same graph?

One way is to make use of the ROC Table which exists after you choose to make the ROC plot. Basically, for each test make the ROC Table into a data table, concatenate them using the option to create a new column identifying the source tables, then use Overlay Plot with the plots grouped by source table and turning on Overlay by Groups. You can do this interactively or with something like the following example which I pieced together by saving scripts after doing it interactively:



dt = open("$SAMPLE_DATA/Fitness.jmp");

fm = dt << Fit Model(

    Y( :Sex ),

    Effects( :Oxy ),

    Personality( Nominal Logistic ),

    Run Model(

        Positive
Level( "M" ),

       
Likelihood Ratio Tests( 1 ),

        Wald
Tests( 0 ),

        ROC
Curve( 1 ),

        Logistic
Plot( 1 ),

       
SendToReport(

       
    Dispatch( {"Receiver Operating
Characteristic"}, "ROC Table", OutlineBox, Close( 0 ) )

        )

    )

);

fmReport = Report( fm );

fmReport["ROC Table"][Table Box( 1 )] << make into data
table;

data table(1)  << set name("Oxy");



fm = dt << Fit Model(

    Y( :Sex ),

    Effects( :Runtime ),

    Personality( Nominal Logistic ),

    Run Model(

        Positive
Level( "M" ),

       
Likelihood Ratio Tests( 1 ),

        Wald
Tests( 0 ),

        ROC
Curve( 1 ),

        Logistic
Plot( 1 ),

       
SendToReport(

       
    Dispatch( {"Receiver Operating
Characteristic"}, "ROC Table", OutlineBox, Close( 0 ) )

        )

    )

);

fmReport = Report( fm );

fmReport["ROC Table"][Table Box( 1 )] << make into data
table;

data table(1)  << set name("Runtime");



Concatenate(

    Data Table( "Runtime" ),

    Data Table( "Oxy" ),

    Output Table( "Both" ),

    Create source column

);



Overlay Plot(

    X( :Name( "1-Specificity" ) ),

    Y( :Sensitivity ),

    Grouping( :Source Table ),

    Overlay Groups,

    Step( 1 ),

    Show Points( 0 ),

    SendToReport(

        Dispatch(

       
    {},

       
    "106",

       
    ScaleBox( 2 ),

       
    {Format( "Best", 10 ), Show Major Grid(
1 )}

        ),

        Dispatch(
{}, "101", ScaleBox( 2 ), {Show Major Grid( 1 )} )

    )

);




style="margin-bottom: 0.0001pt; line-height: normal;">
style="font-size: 10pt; font-family: "Courier New"; color: navy;">

style="font-size: 10pt; font-family: "Courier New"; color: black;">

View solution in original post

mpb
mpb
Level VII

Re: How do I display multiple ROC curves on the same graph?

Same thing using Fit Y by X platform and Make Combined Data Table:



dt = open("$SAMPLE_DATA/Fitness.jmp");

New Window( "Fitness- Fit Y by X of Sex",

    H List Box(

        LogOxy =
Logistic(

       
    Y( :Sex ),

       
    X( :Oxy ),

       
    Positive Level( "M" ),

       
    ROC Curve,

       
    SendToReport(

       
        Dispatch(

       
       
    {"Receiver Operating Characteristic"},

       
       
    "ROC Table",

       
       
    OutlineBox,

       
       
    Close( 0 )

       
        )

       
    )

        ),

       
LogRuntime = Logistic(

       
    Y( :Sex ),

       
    X( :Runtime ),

       
    Positive Level( "M" ),

       
    ROC Curve,

       
    SendToReport(

       
        Dispatch(

       
       
    {"Receiver Operating Characteristic"},

       
       
    "ROC Table",

       
       
    OutlineBox,

       
       
    Close( 0 )

       
        )

       
    )

        )

    )

);

Logrep = Report(LogOxy);

Logrep["ROC Table"][Table Box( 1 )] << make combined data
table;

data table(1) << set name("Both");



Overlay Plot(

    X( :Name( "1-Specificity" ) ),

    Y( :Sensitivity ),

    Grouping( :X ),

    Overlay Groups,

    Step( 1 ),

    Show Points( 0 ),

    SendToReport(

        Dispatch(

       
    {},

       
    "106",

       
    ScaleBox( 2 ),

       
    {Format( "Best", 10 ), Show Major Grid(
1 )}

        ),

        Dispatch(
{}, "101", ScaleBox( 2 ), {Show Major Grid( 1 )} )

    )

);


View solution in original post

5 REPLIES 5

Re: How do I display multiple ROC curves on the same graph?

I was wondering the same thing, anyone know the answer?
mpb
mpb
Level VII

Re: How do I display multiple ROC curves on the same graph?

One way is to make use of the ROC Table which exists after you choose to make the ROC plot. Basically, for each test make the ROC Table into a data table, concatenate them using the option to create a new column identifying the source tables, then use Overlay Plot with the plots grouped by source table and turning on Overlay by Groups. You can do this interactively or with something like the following example which I pieced together by saving scripts after doing it interactively:



dt = open("$SAMPLE_DATA/Fitness.jmp");

fm = dt << Fit Model(

    Y( :Sex ),

    Effects( :Oxy ),

    Personality( Nominal Logistic ),

    Run Model(

        Positive
Level( "M" ),

       
Likelihood Ratio Tests( 1 ),

        Wald
Tests( 0 ),

        ROC
Curve( 1 ),

        Logistic
Plot( 1 ),

       
SendToReport(

       
    Dispatch( {"Receiver Operating
Characteristic"}, "ROC Table", OutlineBox, Close( 0 ) )

        )

    )

);

fmReport = Report( fm );

fmReport["ROC Table"][Table Box( 1 )] << make into data
table;

data table(1)  << set name("Oxy");



fm = dt << Fit Model(

    Y( :Sex ),

    Effects( :Runtime ),

    Personality( Nominal Logistic ),

    Run Model(

        Positive
Level( "M" ),

       
Likelihood Ratio Tests( 1 ),

        Wald
Tests( 0 ),

        ROC
Curve( 1 ),

        Logistic
Plot( 1 ),

       
SendToReport(

       
    Dispatch( {"Receiver Operating
Characteristic"}, "ROC Table", OutlineBox, Close( 0 ) )

        )

    )

);

fmReport = Report( fm );

fmReport["ROC Table"][Table Box( 1 )] << make into data
table;

data table(1)  << set name("Runtime");



Concatenate(

    Data Table( "Runtime" ),

    Data Table( "Oxy" ),

    Output Table( "Both" ),

    Create source column

);



Overlay Plot(

    X( :Name( "1-Specificity" ) ),

    Y( :Sensitivity ),

    Grouping( :Source Table ),

    Overlay Groups,

    Step( 1 ),

    Show Points( 0 ),

    SendToReport(

        Dispatch(

       
    {},

       
    "106",

       
    ScaleBox( 2 ),

       
    {Format( "Best", 10 ), Show Major Grid(
1 )}

        ),

        Dispatch(
{}, "101", ScaleBox( 2 ), {Show Major Grid( 1 )} )

    )

);




style="margin-bottom: 0.0001pt; line-height: normal;">
style="font-size: 10pt; font-family: "Courier New"; color: navy;">

style="font-size: 10pt; font-family: "Courier New"; color: black;">

mpb
mpb
Level VII

Re: How do I display multiple ROC curves on the same graph?

Same thing using Fit Y by X platform and Make Combined Data Table:



dt = open("$SAMPLE_DATA/Fitness.jmp");

New Window( "Fitness- Fit Y by X of Sex",

    H List Box(

        LogOxy =
Logistic(

       
    Y( :Sex ),

       
    X( :Oxy ),

       
    Positive Level( "M" ),

       
    ROC Curve,

       
    SendToReport(

       
        Dispatch(

       
       
    {"Receiver Operating Characteristic"},

       
       
    "ROC Table",

       
       
    OutlineBox,

       
       
    Close( 0 )

       
        )

       
    )

        ),

       
LogRuntime = Logistic(

       
    Y( :Sex ),

       
    X( :Runtime ),

       
    Positive Level( "M" ),

       
    ROC Curve,

       
    SendToReport(

       
        Dispatch(

       
       
    {"Receiver Operating Characteristic"},

       
       
    "ROC Table",

       
       
    OutlineBox,

       
       
    Close( 0 )

       
        )

       
    )

        )

    )

);

Logrep = Report(LogOxy);

Logrep["ROC Table"][Table Box( 1 )] << make combined data
table;

data table(1) << set name("Both");



Overlay Plot(

    X( :Name( "1-Specificity" ) ),

    Y( :Sensitivity ),

    Grouping( :X ),

    Overlay Groups,

    Step( 1 ),

    Show Points( 0 ),

    SendToReport(

        Dispatch(

       
    {},

       
    "106",

       
    ScaleBox( 2 ),

       
    {Format( "Best", 10 ), Show Major Grid(
1 )}

        ),

        Dispatch(
{}, "101", ScaleBox( 2 ), {Show Major Grid( 1 )} )

    )

);


QS
QS
Level I

Re: How do I display multiple ROC curves on the same graph?

Thanks mpb.

 

That was a great solution. tried and it worked right away.

 

Thumbs up.

eliyahu100
Level III

Re: How do I display multiple ROC curves on the same graph?

You could create a graph using the following scripts which puts on a new graph the reference line and two ROC curve lines.

The values for the ROC curves are obtained by right clicking on the ROC curve graph you obtained in the analysis window and choosing "customize", then in the script window you get the script of the line. You could copy those and paste them in the script below replacing the lines that are currently their. repeat this for every ROC curv you want to add.

Hope this helps.

eliyahu100_0-1594914959845.png

 

New Window( "ROC Curve",
	Graph Box(
			FrameSize( 600, 600 ),
			X Scale( 0, 1 ),
			Y Scale( 0, 1 ),
			
			//add axis titles
			xName( "1-Specificity" ),
			yName( "Sensitivity" ),
			
			//add reference line 
			Line Style( 0 );
			Y Function( XTemp , XTemp  );
			
			//add first line
			Line Style( 1 );
			Text Size( 12 );
			Text({0.45, 0.2}, "......... Group, BMI; AUC = 0.88");
			pen size(2);
			Line(
					[0, 0, 0, 0, 0, 0, 0, 0.153846153846154, 0.230769230769231, 0.230769230769231,
					0.307692307692308, 0.384615384615385, 0.384615384615385, 0.461538461538462,
					0.461538461538462, 0.538461538461539, 0.615384615384615, 0.692307692307692,
					0.769230769230769, 0.846153846153846, 0.923076923076923, 1, 1],
					[0, 0.111111111111111, 0.222222222222222, 0.333333333333333, 0.444444444444444,
					0.555555555555556, 0.666666666666667, 0.666666666666667, 0.666666666666667,
					0.777777777777778, 0.777777777777778, 0.777777777777778, 0.888888888888889,
					0.888888888888889, 1, 1, 1, 1, 1, 1, 1, 1, 1]
				);
				
				//add second line
				Line Style( 4 );
				Text Size( 12 );
				Text( {0.45, 0.1}, "_.._.._.._ Group, BMI, Endo; AUC = 0.96" );
				Line(
						[0, 0, 0, 0, 0, 0, 0, 0.0833333333333333, 0.0833333333333333, 0.166666666666667,
						0.25, 0.25, 0.333333333333333, 0.416666666666667, 0.5, 0.583333333333333,
						0.666666666666667, 0.75, 0.833333333333333, 1, 1],
						[0, 0.222222222222222, 0.333333333333333, 0.444444444444444, 0.555555555555556,
						0.666666666666667, 0.777777777777778, 0.777777777777778, 0.888888888888889,
						0.888888888888889, 0.888888888888889, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
					);
		);

	);