cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
marcstein
Level II

How to return AUC for a column as a single value (not a graph)?

I can use the following to generate an ROC curve which contains the AUC value.

 

 

Names Default To Here( 1 );
Open( "RESULTS.jmp" );
Logistic( Y( :IsDef ), X( :Interest ), Positive Level( 0 ), ROC Curve );

 

 

This generates a graphical curve. I have a table with 80 columns and I want to calculate the AUC value for each column and simply return each as a numerical value. I don't want to generate the graphic representation. Is there a formula that could be used within the sheet itself?

Many thanks in advance for any assistance!

 

Marc

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to return AUC for a column as a single value (not a graph)?

Here is a simple example to do what you are trying to do

Names Default To Here( 1 );

// Open and example data table
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get the columns to be analyzed
colNamesList = dt << get column names( string, continuous );

// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "Column", character ), New Column( "AUC" ) );

// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++,
	// Add a new row to the output data table
	dtOutput << Add Rows( 1 );
	// Add the active variable name to the current row in the data table
	dtOutput:Column[i] = colNamesList[i];
	// Run the Logistic Regression
	theLog = dt << Logistic( invisible, Y( :sex ), X( Column( colNamesList[i] ) ), Positive Level( "F" ), ROC Curve );
	// Add the AUC to the data table by grabbing it from the display report output
	dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][Number Col Box( 1 )] << get)[1];
	// Close the report window
	Report( theLog ) << close window;
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How to return AUC for a column as a single value (not a graph)?

Here is a simple example to do what you are trying to do

Names Default To Here( 1 );

// Open and example data table
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get the columns to be analyzed
colNamesList = dt << get column names( string, continuous );

// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "Column", character ), New Column( "AUC" ) );

// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++,
	// Add a new row to the output data table
	dtOutput << Add Rows( 1 );
	// Add the active variable name to the current row in the data table
	dtOutput:Column[i] = colNamesList[i];
	// Run the Logistic Regression
	theLog = dt << Logistic( invisible, Y( :sex ), X( Column( colNamesList[i] ) ), Positive Level( "F" ), ROC Curve );
	// Add the AUC to the data table by grabbing it from the display report output
	dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][Number Col Box( 1 )] << get)[1];
	// Close the report window
	Report( theLog ) << close window;
);
Jim
marcstein
Level II

Re: How to return AUC for a column as a single value (not a graph)?

Thanks! It seems an excellent solution, but it only processes 23 out of 75
values. The script runs fully and successfully with no debugging errors,
yet fails to process numeric columns that can be processed manually.

Any idea why?

Here's the script as running:

Names Default To Here( 1 );

// Open and example data table
dt = Open( "RESULTS3.jmp" );

// Get the columns to be analyzed
colNamesList = dt << get column names( string, continuous );

// Create a data table to save the results to
dtOutput = New Table( "AUCResults", New Column( "Column", character ), New Column( "AUC" ) );

// Loop across all of the columns to be analyzed and retrieve the AUC
For( i = 1, i <= N Items( colNamesList ), i++, 

// Add a new row to the output data table
	dtOutput << Add Rows( 1 );

// Add the active variable name to the current row in the data table
	dtOutput:Column[i] = colNamesList[i];

// Run the Logistic Regression
	theLog = dt << Logistic( invisible, Y( :isDef ), X( Column( colNamesList[i] ) ), Positive Level( "0" ), ROC Curve );

// Add the AUC to the data table by grabbing it from the display report output
	dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][Number Col Box( 1 )] << get)[1];

// Close the report window
	Report( theLog ) << close window;
);




Many thanks for the assistance!


Best,


Marc

txnelson
Super User

Re: How to return AUC for a column as a single value (not a graph)?

My first question is, do you understand how the script I provided works?  The simple example was not provided under the assumption that it work work with the real data.  The key line is

dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][Number Col Box( 1 )] << get)[1];

I assume that there is something different in the way JMP is displaying the columns that work with this line of code vs. the ones that do not.  I suggest you manually look at the differences, and then figure out what is different and then adapt the code to handle both cases.  And there may be more than two cases you will have to deal with.

Jim
marcstein
Level II

Re: How to return AUC for a column as a single value (not a graph)?

Perfect!

 

Thanks so much!

 

Marc