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
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.
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:
- Added column to store X values used in calculations
- Added column to store Y values used in calculations
Version 1.2:
- Modified loop variable for by variables from
loops = Round(NRows(allrows_byLvl) / npts ) to loops = Round(length(allrows_byLvl) / incby )
- modified startrow and endow from
incStartrow# = incStartrow# + incby -1 to incStartrow# = incStartrow# + incby
incEndrow# = incEndrow# + incby - 1 to incEndrow# = incEndrow# + incby