cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Slope and Intercept Collector
stan_koprowski
Community Manager Community Manager

Here is an example of a JMP add-in that will calculate the slope and intercepts for a given Y, response and X, regressor variables.  Optionally you may include one or more by variables.

 

The defaults are as follows:

  • Number of points (# Pts) is set to 10
  • Increment by is set to 5
  • Start at Row is set to 1

 

11954_Screenshot 2016-07-06 14.44.39.png

 

Using the Abrasion.jmp data table from the sample data and the selections noted above will yield the following output.

A new data table is created with the name of the original data table appended to "Slope Estimates" forming the name in this example as "Slope Estimates Abrasion.jmp".

 

//Get table name

dtfn = dt<< Get Name;

dtn = Word(1, dtfn, ".");

 

// Create name for new table

 

tbln = "Slope Estimates " || dtn;

 

One row for each slope and intercept calculation is added to the new data table.  It will also add which rows were used in the calculation and the starting parameters for "# Pts", "Increment By", "Start at Row" and any variables cast into roles.

 

Because the table takes advantage of the new data type in JMP 12 called Expression to store the rows matrix it is only compatible with JMP 12 or newer.

12949_Screenshot 2016-10-07 19.06.31.png

 

The add-in demonstrates the use of a custom launch to reset the defaults or to recall the previous values the last time it was run during the current JMP session.

 

A great example of the creation of a custom launch window.

 

 

*********************** Updated **********************************

Version 1.1:

  1. Added column to store X values used in calculations
  2. Added column to store Y values used in calculations

Version 1.2: 

  1. Modified loop variable for by variables from

    loops = Round(NRows(allrows_byLvl) / npts ) to loops = Round(length(allrows_byLvl) / incby )

  2. modified startrow and endow from 

    incStartrow# = incStartrow# + incby -1 to incStartrow# = incStartrow# + incby

    incEndrow# = incEndrow# + incby - 1 to incEndrow# = incEndrow# + incby

Comments
tejvishnu

Thank you Stanley. This has been extremely valuable.

Would it be possible to modify the add-in and add a column which would have the corresponding row values (data format being an expression just like the row numbers) associated with the calculation in addition to the row numbers used for calculating the slope and interecept?

Thanks again..

Hi,

I'll take a look and post an updated version of the add-in as soon as possible.

Thanks for your interest in the add-in.

Stan

tejvishnu

Thanks Stan - I greatly appreciate your help..

tejvishnu

Hello Stan,

Any updates on the modified add-in? I'll be on the lookout.

Thanks..

Hello,

I'll post an update later this week.

Thank you for your patience.

Cheers,

Stan

tejvishnu

Thanks Stan - This is exactly what I was looking for. This revised add-in will help automate an otherwise very tedious process that I was using in the past.

Regards..

nkhajouei

Hi Stan, I am trying to slice my time series data and calculate slope for each slice. Because I have a high dimension data set, I imagine your tool might be extremely handy and I won't have to recreate it. It's just that I am running into issues.

 

I am getting this error where it says "matrix must be non-singular in access or evaluation of 'Inv', Inc/*###*/(x`*x)

 

Do you have any hints? Also, is there any way I can get my hands on the script in the background to modify to my specific needs?

jetpeach

hmm, i'm getting an error that this wont' work with JMP11. any thoughts?

thanks

Hi,
Unfortunately, because the add-in is using a new data type (Expression) introduced in JMP 12 it is only compatible with versions 12 or newer.
 
best,
Stan
kaks

I just noticed there is a couple of errors in the byCalcExpr function.

 

Loops are currently defined as:

loops = Round(NRows(allrows_byLvl) / npts);

Should be changed to:

loops = Round(length(allrows_byLvl) / incby );

 

and increments of start and end rows should not be subtracted 1. So change the following:

incStartrow# = incStartrow# + incby -1;
incEndrow# = incEndrow# + incby - 1;

to:

incStartrow# = incStartrow# + incby;
incEndrow# = incEndrow# + incby ;

Hi @kaks ,

I'll take a look at the changes you suggested and modify accordingly.

Thanks again for your time and support.

Stan

Lavik17

Hi @stan_koprowski, this add-in looks great but I am getting this error: 

matrix must be non-singular in access or evaluation of 'Inv' , Inv/*###*/(x` * x)

I am using JMP 16.2 and this is the data that I am trying to process using the add-in, along with the error message:

 

Lavik17_2-1670623198287.png

 

Hi @Lavik17 ,

Not all the data is visible in the image and to further troubleshoot it would be helpful to have a JMP data table.

Would it be possible to attach your data table to this post so I can take a look.

Stan

Lavik17

@stan_koprowski sorry about that but I don't see the "attach" option available here and when I drag the file over it says file type .jmp is not supported... I hope that this image will help. Otherwise please let me know how may I upload the file or send it to you privately.

Thank you!!

Lavik17_0-1672861965448.png

 

 

Recommended Articles