cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
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

4 REPLIES 4

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!