turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How to calculate slope and intercept

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 3, 2017 11:24 PM
(2092 views)

Hello,

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

- I did not find an easy way to get the Slope and intercept except the use of "Bivariate + fit line"
- 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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 4, 2017 2:18 AM
(3027 views)

Solution

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 6, 2017 5:51 AM
(2954 views)

Solution

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.

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 4, 2017 2:18 AM
(3028 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 4, 2017 3:06 AM
(2077 views)

Thanks Ron,

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 6, 2017 5:51 AM
(2955 views)