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
samir
Level IV

How to calculate slope and intercept

Hello,

I am facing 2 issues when trying tocalculate Slope and Intercept values:

  1. I did not find an easy way to get the Slope and intercept except the use of "Bivariate + fit line"
  2. Using the Bivariatein a loop seems to result in a slow execution of the code: I think that creating a table and the associated fit lile  several times is very slow

My question: is there a way to get the slope and intercept without using the bivariate to get faster ?

 

Here is the code I use in a loop to extract the slopes and intercepts:

biv1 = Bivariate( Y( MyTab:X ), X( MyTab:Y ), Fit Line( {Line Color( "Red" )} ) );
	colBox = Report( biv1 )[Number Col Box( 7 )];
	beta = colBox << GetAsMatrix;
	My_Slope = beta[2];   // slope
	My_Intercept = beta[1];   // intercept
	Close( MyTab, nosave );
);

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
ron_horne
Super User (Alumni)

Re: How to calculate slope and intercept

for starters, have a look at this option:

http://www.pega-analytics.co.uk/blog/linear-regression-matrix-form/

it is a solution offered by David Burnham in his blog. using matrix calculations he achieves high speeds for calculating the regression coefficients.

 

best,

ron

View solution in original post

ian_jmp
Level X

Re: How to calculate slope and intercept

Rather than having a loop, you could also consider making a big table with a 'By' variable, sticking with the Bivariate platform, then using 'Make Combined Data Table'. I expect the matrix approach will be faster, though.

View solution in original post

5 REPLIES 5
ron_horne
Super User (Alumni)

Re: How to calculate slope and intercept

for starters, have a look at this option:

http://www.pega-analytics.co.uk/blog/linear-regression-matrix-form/

it is a solution offered by David Burnham in his blog. using matrix calculations he achieves high speeds for calculating the regression coefficients.

 

best,

ron

samir
Level IV

Re: How to calculate slope and intercept

Thanks Ron,

That's what I was looking for: I will implement and test the spead :)

ian_jmp
Level X

Re: How to calculate slope and intercept

Rather than having a loop, you could also consider making a big table with a 'By' variable, sticking with the Bivariate platform, then using 'Make Combined Data Table'. I expect the matrix approach will be faster, though.

RyMcQeN
Level III

Re: How to calculate slope and intercept

Hi Ian,

 

I have followed your approach using the 'By' variable and sticking with the bivariate platform. I am not sure of the correct syntax for 'Make Combined Data Table' to work for multiple Fit Lines.  Can you help?

 

kXPlot = dt << Bivariate( Y( :LMS_dX ), X( :X_Nominal ), By(Column(::bcol)), Fit Line());
kXPlotDT = kXPlot < ???

Thank you,

 

Ry

 

RyMcQeN
Level III

Re: How to calculate slope and intercept

I figured it out.

kXPlotDT = Report( kXPlot )["Parameter Estimates"][Table Box(1)] << Make Combined Data Table;

Regards,

Ry