cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
MathStatChem
Level VI

Create prediction expression display based on column formula

I would like to create a formatted prediction expression, based on a column formula, in a custom report window.  When I fit a linear model using Fit Least Squares, in the model report, I can turn on the display of the prediction expression, which displays a formatted "picture" view of the equation.

 

I can then save the equation to the data table as a column with a formula.  

 

Now I want to select that column and display a prediction expression for the formula saved to the column, all by itself, in a new report window.  

 

Is there a way to do this with JSL?  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Create prediction expression display based on column formula

If you're looking for a picture of the prediction expression you can use Expr As Picture().

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Drug.jmp" );
obj = dt << Fit Model(
	Y( :y ),
	Effects( :Drug, :x ),
	Personality( Standard Least Squares ),
	Emphasis( Minimal Report ),
	Run
);
obj << Prediction Formula;


New Window( "Example",
	Lineup Box( N Col( 1 ), spacing( 10 ),
		Text Box( "Column Formula" ),
		Border Box( Left( 10 ), Right( 10 ), bottom( 10 ), top( 10 ), sides( 15 ),
			Expr As Picture( dt:pred formula y << get formula )
		)
	)
);

2020-09-10_13-27-50.507.png

-Jeff

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Create prediction expression display based on column formula

You can simply retrieve the formula with a <<get formula message passed to the column.

Names Default To Here( 1 );
dt = New Table( "Example",
	add rows( 10 ),
	New Column( "The Column", formula( Random Integer( 1, 100 ) ) )
);

theFormla = dt:The Column << get formula;
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: Create prediction expression display based on column formula

If you're looking for a picture of the prediction expression you can use Expr As Picture().

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Drug.jmp" );
obj = dt << Fit Model(
	Y( :y ),
	Effects( :Drug, :x ),
	Personality( Standard Least Squares ),
	Emphasis( Minimal Report ),
	Run
);
obj << Prediction Formula;


New Window( "Example",
	Lineup Box( N Col( 1 ), spacing( 10 ),
		Text Box( "Column Formula" ),
		Border Box( Left( 10 ), Right( 10 ), bottom( 10 ), top( 10 ), sides( 15 ),
			Expr As Picture( dt:pred formula y << get formula )
		)
	)
);

2020-09-10_13-27-50.507.png

-Jeff
MathStatChem
Level VI

Re: Create prediction expression display based on column formula

Thanks, that's what I needed.  I knew there was a way to do it, I just couldn't remember the Expr as Picture() box display object.  

MathStatChem
Level VI

Re: Create prediction expression display based on column formula

It has been a while since I posted this a got a good answer.  I wanted to share the script I developed to allow for quickly viewing the formulas in columns in a data table, allowing to switch columns interactively.

 

/* this script presents a list of columns in the current data table
in a list box, and upon selecting a column, if the column has a formula, 
it will display the formula below the list box as a picture.  
If the column does not have a formula, "No Column Formula" is displayed
*/

Names Default To Here( 1 );
_dt = Current Data Table();

expr_ShowFormulaAsPicture = Expr(
	_vb1 << Delete;
	_vb << Append( _vb1 = V List Box() );
	_c = Column( dt, (_clb << Get Selected)[1] );
	If( Is Empty( _c << Get Property( "Formula" ) ),
		_vb1 << Append( Text Box( "No Column Formula" ) ),
		_vb1 << Append( Picture Box( Expr As Picture( _c << get formula ) ) )
	);
);


New Window( "Show Column Formula as Picture",
	_vb = V List Box(
		
	)
);

_vb << Append(
	_pb = Panel Box( "Select Column With Formula To Display as Picture",
		_clb = Col List Box(
			_dt,
			max selected( 1 ),
			grouped,
			all,
			On Change( expr_ShowFormulaAsPicture )
		)
	)
);

_vb << Append( _vb1 = V List Box() );

Example window here:

MathStatChem_0-1613243082768.png