cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jakinsanya
Level I

Extracting slope from Fit Special

I have two variables X & Y that I fitted a line with the y - intercept constrained to 0.

I need the slope value from this line for a subsequent calculation.

Is there anyway to save this slope value in a column so that I can use it for the subsequent calculation.

Bivariate(
Y( :Y ),
X( :X ),
Fit Special( Intercept( 0 ),

2 REPLIES 2
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Extracting slope from Fit Special

If you are just trying to find the coefficients while working interactively you can look in the 'Parameter Estimates' table inside the Bivariate fit platform.  If you want to pull this out with a script, there are a few options, one is to turn that Parameter Estimates table into a data table and get it from there:

 

ih_0-1620304269767.png

 

Names Default To Here( 1 );

//Sample data
dt = Open("$Sample_data/iris.jmp");

//Fit line
bv = dt << Bivariate(
	Y( :Sepal length ),
	X( :Sepal width ),
	Fit Special( Intercept( 0 ), {Line Color( {212, 73, 88} )} )
);
Wait( 0 );

//Save estimates to a table
dtEstimates = Report( bv )[Outline Box( "Bivariate Fit of Sepal length By Sepal width" )][
Outline Box( "Linear Fit" )][Outline Box( "Parameter Estimates" )][Table Box( 1 )]
 << Make Into Data Table;
 
// Pull estimate out of data table
dtEstimates:Estimate[dtEstimates << Get Rows Where(:Term == "Sepal width")][1];

// Clean up
// Report( bv ) << Close Window;
// dtEstimates << Close Window;
SDF1
Super User

Re: Extracting slope from Fit Special

Hi @jakinsanya ,

 

  One (of many) ways you can do this is after performing the fit, the very bottom table in the report, Parameter Estimates, you can right click in the table and select Make Into Data Table. The Column called Estimate will contain the value of the intercept (0) and slope.

 

  I suggest testing this out with the Big Class.jmp data table just to get familiar with how to do it before moving on to more complicated tables.

 

  One can always script something to pull the values from the report and save it to the data table and perform all sorts of math, but it's unclear the extent to which you want to make this automated and/or more "complex" with scripts (it's not really complex, just takes some overhead in time at the start to sort things out, but makes your life easier in the end, especially if you have to repeat the process many times).

 

Hope this helps!,

DS

 

  Let me know if you want a script, and I can generate an example for you.