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

How to extract fitted line equations?

I have 60 Bivariate plots and each plot is fitted with a line. How can I extract the line parameter using script?
For example, the fitted line is y=ax+b, how can i get a and b and save them into variables. When i try to use tree structure, it only shows the tree for first plot, and the command to grab values from boxes doesn't work.
Anyone knows how to do that? thanks in advance!

Message was edited by: Schweini
1 ACCEPTED SOLUTION

Accepted Solutions
mpb
mpb
Level VII

Re: How to extract fitted line equations?

This is a somewhat shorter method that uses the built in "make combined data table" command to produce a table containing all the parameters which you can slice and dice as required.

//Opendatatable and make report

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = Bivariate(
    Y( :weight ),
    X( :height ),
    Fit Line( {Line Color( "Red" )} ),
    By( :age )
);

rbiv = biv << report;

//Combine parameter estimates in new table

dtparms = rbiv[1][tablebox(4)] << make combined data table;

dtparms << Set Name("Parameter Table");

View solution in original post

5 REPLIES 5

Re: How to extract fitted line equations?

A crude, non-script solution is to run regressions, save as text then copy into Excel. Use the text filter function to extract equations from text and copy into new worksheet. Rest can be done with text to columns function. Has to be a better way but this works for me.
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to extract fitted line equations?

Here is an example script generating a table with the parameter estimates. The script assumes that the different plots are generated using the "by" command/box in the Bivariate platform.

//Open datatable and make report
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = Bivariate(
	Y( :weight ),
	X( :height ),
	Fit Line( {Line Color( "Red" )} ),
	By( :age )
);
rbiv = biv << report;

Summarize( groups = by( age ) ); // A list of all by-groups
n = N Items( groups );

//Create output table and fill with estimates
dtOut = New Table( "Regression parameters",
	New Column( "Group", Character ),
	New Column( "Intercept", numeric ),
	New Column( "Slope", numeric ),
	addrows( n ));
	
For( j = 1, j <= n, j++,
	Estimates = rbiv[j]["Linear Fit"]["Parameter Estimates"][1][3] << get as matrix;
	:Group[j] = groups[j];
	:Intercept[j] = Estimates[1];
	:Slope[j] = Estimates[2]);
mpb
mpb
Level VII

Re: How to extract fitted line equations?

This is a somewhat shorter method that uses the built in "make combined data table" command to produce a table containing all the parameters which you can slice and dice as required.

//Opendatatable and make report

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = Bivariate(
    Y( :weight ),
    X( :height ),
    Fit Line( {Line Color( "Red" )} ),
    By( :age )
);

rbiv = biv << report;

//Combine parameter estimates in new table

dtparms = rbiv[1][tablebox(4)] << make combined data table;

dtparms << Set Name("Parameter Table");

Re: How to extract fitted line equations?

@MShroff FYI, this is a very nice solution RE: our somewhat recent discussion on effectively extracting out the equations from the Bivariate report. It includes the specification of the By() role and no For() loop is needed!

hogi
Level XII

Re: How to extract fitted line equations?

If you need the fit results to generate a formula column, there is a very convenient shortcut via Graph Builder:

hogi_0-1724508747726.png

 

which can be scripted via:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = dt << Graph Builder(
	Variables( X( :height ), Y( :weight ), Overlay( :age ) ),
	Elements(
		Line Of Fit( X, Y,  Confidence of Fit( 0 ) ),
		Points( X, Y )
	)
);
gb << Update Element( 1, 1,1 {Save Formula} );