I am trying to calculate the AUC for each column in a data table. I am collecting all of the column names into a list "colNamesList", and retrieving each column name in Fit Model inside a For loop by incrementing the list subscript. However, the call to the array is not resolving inside the Fit Model call. If I include show(colNamesList[i]) on a separate line, it resolves fine, just not inside the Fit Model call. I am using a script from a prior post in this forum, and I suspect that my older version of JMP (version 9.0.0) just needs slightly different syntax. Any ideas would be appreciated.
Names Default To Here( 1 );
// Open and example data table
dt = Open( "sample.jmp" );
// Get the columns to be analyzed
colNamesList = dt << get column names( string );
// Create a data table to save the results to
dtOutput = New Table( "Results", New Column( "var_name", character ), New Column( "AUC", character ) );
// 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:var_name[i] = colNamesList[i];
// Run the Logistic Regression
theLog = dt << Fit Model(invisible, Y( :case ),Effects( column (colNameList[i]) ),Personality( Nominal Logistic ),Run(Positive Level( "1" ),Likelihood Ratio Tests( 1 ),ROC Curve( 1 ),));
// Add the AUC to the data table by grabbing it from the display report output
dtOutput:AUC = (Report( theLog )["Receiver Operating Characteristic"][numberbox(1)] << get text);
// Close the report window
Report( theLog ) << close window;
);
The error in the log is as follows:
Name Unresolved: colNameList{1}
in access or evaluation of 'colNameList' , colNameList
Exception in platform launch{1}
in access or evaluation of 'Fit Model' , Fit Model(
invisible,
Y( :case ),
Effects( Column( colNameList[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
)
In the following script, error marked by /*###*/
Fit Model(
invisible,
Y( :case ),
Effects( Column( colNameList/*###*/[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
)
Cannot subscript Display Box{1}
in access or evaluation of 'Subscript' , Report( theLog )["Receiver Operating Characteristic"]
In the following script, error marked by /*###*/
Names Default To Here( 1 );
dt = Open( "sample.jmp" );
colNamesList = dt << get column names( string );
dtOutput = New Table( "Results",
New Column( "var_name", character ),
New Column( "AUC", character )
);
For( i = 1, i <= N Items( colNamesList ), i++,
dtOutput << Add Rows( 1 );
dtOutput:var_name[i] = colNamesList[i];
theLog = dt << Fit Model(/*###*/invisible,
Y( :case ),
Effects( Column( colNameList[i] ) ),
Personality( Nominal Logistic ),
Run( Positive Level( "1" ), Likelihood Ratio Tests( 1 ), ROC Curve( 1 ) )
);
dtOutput:AUC = Report( theLog )[/*###*/"Receiver Operating Characteristic"][
numberbox( 1 )] << get text;
Report( theLog ) << close window;
);