cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
aserino
Level III

Saving R-Square values from smoothing spline fit

Hi all,

 

Is there a way to save the R-Square value from the smoothing spline fit in JSL? I'd like to be able to reference it at a later point.

 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Saving R-Square values from smoothing spline fit

The Output Display's Tree Structure for the output you are looking for, is different than the example I gave.  If you right click on the gray triangle beside the Bivariate Fit of NPN1 By PNP1 outline box(), and then select

     Edit==>Show Tree Structure

You can see the Tree Structure for all of the output.

Below is the script using your output

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	Fit Spline( 100000, {Line Color( {204, 121, 41} )}, {Save Predicteds})
);

// Offset into the report object and get the RSquare value
RSquare = (Report(biv)["Smoothing Spline Fit, lambda=100000"][NumberColBox(1)]<<get)[1] ;
Jim

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Saving R-Square values from smoothing spline fit

All display data in an output table from a JMP platform is available to JSL.  Here is a simple example that retrieves the Smoother RSquare value

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	Kernel Smoother( 1, 1, 0.343642611683849, 0 )
);

// Offset into the report object and get the RSquare value
RSquare = Num(Report(biv)["Local Smoother"][numberbox(1)]<<get text);
Jim
aserino
Level III

Re: Saving R-Square values from smoothing spline fit

Thanks for the reply Jim. The example you gave helps a bit, but it doesn't work exactly the same for a Fit Spline(). What's the problem with the syntax in the following..

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	Fit Spline( 100000, {Line Color( {204, 121, 41} )}, {Save Predicteds})
);

// Offset into the report object and get the RSquare value
RSquare = Num(Report(biv)["Smoothing Spline Fit, lambda=100000"][numberbox(1)]<<get text);

 

The error implies a problem with the numberbox(1).

cwillden
Super User (Alumni)

Re: Saving R-Square values from smoothing spline fit

The R-square value is contained in a number col box in this case, not a number box.  You find the container for the value you want by viewing the tree structure.  See this page for instructions on that:  https://www.jmp.com/support/help/14/view-the-display-tree.shtml

You just need to replace the last line with this:

RSquare = (Report(biv)["Smoothing Spline Fit, lambda=100000"][numbercolbox(1)]<< Get)[1];

The << Get message to the number col box will return a list of values.  You can alternatively use "<< Get As Matrix".  The [1] returns the first list item, which is the R-squared value.

-- Cameron Willden
aserino
Level III

Re: Saving R-Square values from smoothing spline fit

Thanks for the help!
txnelson
Super User

Re: Saving R-Square values from smoothing spline fit

The Output Display's Tree Structure for the output you are looking for, is different than the example I gave.  If you right click on the gray triangle beside the Bivariate Fit of NPN1 By PNP1 outline box(), and then select

     Edit==>Show Tree Structure

You can see the Tree Structure for all of the output.

Below is the script using your output

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	Fit Spline( 100000, {Line Color( {204, 121, 41} )}, {Save Predicteds})
);

// Offset into the report object and get the RSquare value
RSquare = (Report(biv)["Smoothing Spline Fit, lambda=100000"][NumberColBox(1)]<<get)[1] ;
Jim
aserino
Level III

Re: Saving R-Square values from smoothing spline fit

Thanks for the help Jim!
Zihao
Level II

Re: Saving R-Square values from smoothing spline fit

If I add a "by(:SITE)" in the "Bivariate" function, then I will have five plots in the report. How can I extract all five Rsquare value and save it as a new column in the table?

 

Thanks,

Zihao

txnelson
Super User

Re: Saving R-Square values from smoothing spline fit

The Bivariate Platform creates a separate tree structure for each of the By levels.  To access the RSquare value, all that has to be done, is to point to the RSquare value as in the single Bivariate execution, but to add a subscript for which one of the RSquares outputs you want.  Below is a simple modification to the script, to place the RSquare values for all 5 sites into a new data table

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	Fit Spline( 100000, {Line Color( {204, 121, 41} )}, {Save Predicteds} ),
	by( :site )
);

// Offset into the report object and get the RSquare value
RSquare = {};
For( i = 1, i <= N Items( biv ), i++,
	Insert Into(
		RSquare,
		(Report( biv[i] )["Smoothing Spline Fit, lambda=100000"][Number Col Box( 1 )]
		 << get)[1]
	)
);

dtRSquare = New Table( "RSquareTable", New Column( "RSquares", values( RSquare ) ) );

 To fully understand how to deal with the Output Display Trees created by JMP, strongly suggest that you read the section on Display Trees in the Scripting Guide

     Help==>Books==>Scripting Guide

Jim