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
- :
- Calculating area between two spline fits (bivariat...

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

Jan 18, 2010 4:03 PM
(1302 views)

I could certainly do this in matlab with some effort, but it would be neat keep to the entire workflow within JMP. I think my approach would involve summing up slices which geometry is determined by the spline prediction formula matrix. However I am not sure how to interpret and use the prediction formula.

Any ideas that may lead me in the right direction on how to tackle this problem using JMP/JSL? Thanks!

5 REPLIES

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

Jan 20, 2010 2:15 PM
(1000 views)

"The cubic spline method uses a set of third-degree polynomials spliced together such that the resulting curve is continuous and smooth at the splices (knot points). The estimation is done by minimizing an objective function that is a combination of the sum of squares error and a penalty for curvature integrated over the curve extent. See the paper by Reinsch (1967) or the text by Eubank (1988) for a description of this method."

When you fit a spline in Fit Y by X there is a red triangle pull down menu with an item to Save Coefficients. This action creates a new table with columns X, A, B, C, D. Column X contains the unique X values from the data in ascending sort order. The other 4 columns are the coefficients of the third-degree polynomial used in an interval starting with the value of X for the same row up to the value of X for the next row. If the value for X in the same row is X1 then the polynomial for the interval is:

A + B*(X-X1) + C*(X-X1)^2 + D*(X-X1)^3

which is used for X up to X2, the next "knot". To find the exact area under this curve between x1 and x2, simply integrate this polynomial from X1 to X2 to get:

A*(X2-X1) + (B*(X2-X1)^2)/2 + (C*(X2-X1)^3)/3 + (D*(X2-X1)^4)/4

You need to make a new column called Area Slice and put in this formula. In the JMP formula, use X for X1 and Lag(X,-1) for X2. Then you will have a column of Area Slices. You can then add all of the area slices to get the total area under the curve from start to finish. You can also make a column of cumulative areas if you want to.

This gives you an exact value, not an approximation, for the area under the spline.

This can probably be scripted but I haven't tried.

To get the area between 2 such curves, simply find the area this way for both and subtract one from the other.

Michael

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

Jan 22, 2010 12:52 AM
(1000 views)

Btw, there is a problem with the cumulative column. If do it manually by adding the formula

If(Row() == 1, :Slice Area, :Cumulative Area[Row() - 1] + :Slice Area[Row()]) to a column "Cumulative Area" it works. However if I do it by scripting using the command << set formula() I get an error "Illegal Reference (Recursion) at row....". The column is created but without the formula.

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

Jan 22, 2010 4:45 AM
(1000 views)

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

Jan 24, 2010 10:49 AM
(1000 views)

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

Jan 25, 2010 2:46 PM
(1000 views)

The only annoying thing remaining is the Maximize() command that breaks the script if it fails to converge, i.e. find a local maxima. I have not found out how to interact with the error output in JSL (Like "if result==error, then change tolerance and repeat, else Max=result" or similar).

Thanks again!