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
bio_grad
Level III

Calculating linear regression slope in formula

Hello,

 

I was wondering if there was a way to calculate the linear regression slope of column data within a data table formula.

A simple example of the table is below. The data is ordered and I would like to calculate the slope of a fit line of volume over time using the current row's data and previous points to perform the regression.

The idea is that I would like to see the how the calculated slope changes with increasing the number of data points. From doing this manually, the slope values end up approaching a given value and stay within +/-5% after 20 or so points.

InstanceTime (s)Volume (mL)Slope (mL/s)
100n/a
250.5m1
3100.8m2
............
NTVmN-1



If that is possible, my next challenge would be to set this up so that I can calculate the slope formula so that it uses N data points on either side of the current row for a symmetrical moving calculation instead.

 

 

Thank you in advance.

25 REPLIES 25
fat_angus
Level III

Re: Calculating linear regression slope in formula

This is interesting.. if I wanted to apply a p-value to this... based on null hypothesis (slope = 0)... is there a way to integrate this into forumula? 

 

In other words, I would like to see when the moving slope is changing significantly based on confidence interval around slope

 

 

HydroBug
Level II

Re: Calculating linear regression slope in formula

Fantastic solution to EXACTLY what I wanted to do.  Thank you!!

altug_bayram
Level IV

Re: Calculating linear regression slope in formula

Folks interested in this problem may want to consider supporting the wish idea:

https://community.jmp.com/t5/JMP-Wish-List/Moving-Rolling-Window-Statistics/idi-p/722620

 

rdzdec
Level I

Re: Calculating linear regression slope in formula

Hi, 

 

You mention a "span of 3", if we want to modify it to be moving slope of "N" samples, which value will need to change?

 

Thanks!

mksaad
Level I

Re: Calculating linear regression slope in formula

@Mark_Bailey Hi mark, I am new to JMP and am trying to do something similar to bio_grad where I perform linear regression on 3 points, then 4 points, then so on in a column in my data table. I am trying to understand what your answer is actually doing and had a couple of questions. What does || mean? also what is J?
txnelson
Super User

Re: Calculating linear regression slope in formula

J() is a function that creates a matrix of identical values.  The default is 1.

|| is an operator that indicate concatenation.  So in Mark's example he is concatenating 2 matrices.

 

These functions and operators are fully documented in the Scripting Guide

     Help==>JMP Document Library  …..  Scripting Guide

Jim