Subscribe Bookmark RSS Feed

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

Super User

Joined:

Jun 23, 2011

Solution

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");
3 REPLIES
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

Joined:

Jun 23, 2011

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

Super User

Joined:

Jun 23, 2011

Solution

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");