Running Analyze > Fit Y by X. I have the code below which opens a data table but there are no RSquare values in the table. Any ideas on what I'm missing?
// Open Data Table
dt = Data Table( "Raw Data" );
// Run Fit Y by X Analysis with a By Variable
fitObj = dt << Fit Y by X( Y( :"Mean(VALUEABS)" ), X( :Mean ), By( :PARM_LABEL ) );
// Get the analysis report
rpt = fitObj << Get Report;
// Find all RSquare nodes in the report
rsquareNodes = rpt << Find All Matching Elements( "RSquare" );
Show( "Number of RSquare nodes found: " || Char( N Items( rsquareNodes ) ) );
// Initialize a list to store the by group and RSquare pairs
rsquareData = {};
// Loop over each RSquare node found
For( i = 1, i <= N Items( rsquareNodes ), i++,
{
// Extract the RSquare text and convert to numeric value
rsqText = rsquareNodes[i] << Get Text ; rsqVal = Num( rsqText ) ;
// Try to retrieve the by-group label.
parentObj = rsquareNodes[i] << Get Parent ; byLabel = "" ;
While( byLabel == "" & parentObj != {},
byLabel = parentObj << Get Text;
If( byLabel == "",
parentObj = parentObj << Get Parent
);
) ;
// Append the pair (by group label, RSquare value) to list.
Append( rsquareData, {byLabel, rsqVal} ) ; }
);
Show( rsquareData );
// Create a new data table to store the RSquare values by by-group.
rsqDT = New Table( "RSquare Values",
Add Columns(
Column( "By Group", Character, "Nominal" ),
Column( "RSquare", Numeric, "Continuous" )
)
);
// Populate the new data table with the extracted values
For( i = 1, i <= N Items( rsquareData ), i++,
{New Row( rsqDT ) ; rsqDT:("By Group")[Row()] = rsquareData[i][1] ; rsqDT:RSquare[
Row()] = rsquareData[i][2] ; }
);
// Display the new data table
Show( rsqDT );
(Above JSL moved from plain text display to JMP JSL display format) txnelson