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
- :
- Script? Applying non-linear model column formula t...

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

Dec 8, 2016 6:50 AM
(1546 views)

I have a model formula in column 1 with 2 parameters and I would like to fit this model to 80 different data columns (Cols 2 - 82), where each data column has those 2 parameters custom-fit for it. Is there an easy way to do this?

Would I have to write a script?

1 ACCEPTED SOLUTION

Accepted Solutions

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

Dec 12, 2016 7:34 AM
(2747 views)

Solution

Thank you!

Testing now ...

received following error upon debugging

Cannot subscript Display Box in access or evaluation of 'Subscript' , Report( nl fit )[/*###*/"Parameter Estimates"]

markbailey wrote:This solution turns out to be a bit tricky. It only works if the model you are using is NOT one of those in the Fit Curve library. (If it is, then Nonlinear launches Fit Curve, which expects the model to be specified by name, which this script doesn't provide.) Based on your claim that the actual model is more complicated, then I took the chance that it is not in the Fit Model library and wrote this script:

Names Default to Here( 1 ); dlg = Column Dialog( Title( "Nonlinear Regression" ), yCol = Col List( "Y, Response", Data Type( Numeric ), Min Col( 1 ) ), xCol = Col List( "X, Predictor Formula", Data Type( Numeric ), Min Col( 1 ), Max Col( 1 ) ) ); If( dlg["Button"] != 1, Throw( "User cancelled" ); ); Remove From( dlg ); Eval List( dlg ); dt = Current Data Table(); n fits = N Items( yCol ); formula = xCol[1] << Get Formula; n parms = N Items( Arg( formula, 1 ) ); parm = J( n fits, n parms, . ); For( f = 1, f <= n fits, f++, nl fit = dt << Nonlinear( Y( yCol[f] ), X( xCol[1] ), Newton, Finish ); parm[f,0] = Transpose( Report( nl fit )["Parameter Estimates"][NumberColBox(1)] << Get As Matrix ); ); As Table( parm );Open the JMP data table first, then open and run this script. Select all of the response columns (columns 2-82 in your example) and click

Y, Response. Click the column with the model formula (column 1 in your example) and clickX, Predictor Formula, . Then clickOK.

10 REPLIES

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

Dec 8, 2016 12:04 PM
(1493 views)

What is your non-linear model that is stored as a formula in column 1? This formula is usually a function of the predictor variable. Which column holds the predictor values?

If this case is simple, I can write a script.

Learn it once, use it forever!

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

Dec 9, 2016 6:26 AM
(1477 views)

Yes, a predictor variable exists in another column.

We can call it column 83 if you like.

And I suppose my target output would be a table which shows the best fit values of the two parameters per column with associated confidence intervals.

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

Dec 9, 2016 6:35 AM
(1471 views)

I will ask again: what is the non-linear model ( f(X) ) expressed in the column 1 formula? What are the two parameters?

Verifying: predictor (X) is last column and it is used in formula in column 1?

Verifying: the individual responses (Y) are in columns 2-82?

Verifying: you want to fit Y = f(X) separately to each Y and capture the parameter estimates for each Y?

Learn it once, use it forever!

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

Dec 9, 2016 6:47 AM
(1469 views)

Mark,

Thank you.

The responses to all your Verifying questions are yes.

The formula can be anything, but let's say its y = h*exp(-b*x^(0.65)) for simplicity, with h and b as parameters and x>0.

The actual formula is much more complicated, but that extra complication shouldn't impact the solution.

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

Dec 9, 2016 8:22 AM
(1455 views)

You can do it without a script but it will involve a lot of clicking. Assuming that you already have set up the non-linear model as a column formula, follow these steps:

- Select Tables > Stack.
- Select all the response columns (2-82 in your example) and click Stack.
- Make sure that the option to copy the formulas is selected.
- Enter a name for the Data column, such as Response.
- Enter a name for the Label column, such as Curve.
- Click OK.
- Select Analyze > Specialized Models > Nonlinear.
- Select the predictor column (83 in your example) and click X
- Select the model column (1 in your example) and click Y.
- Select the Curve column and click By.
- Click OK.
- Now click Go for each Curve. (This is the tedious part.)
- Right-click on any Parameter Estimates report and select Make Combined Data Table.

This process should give you a new data table with all of the parameter estimates.

Learn it once, use it forever!

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

Dec 11, 2016 10:48 AM
(1418 views)

This solution turns out to be a bit tricky. It only works if the model you are using is NOT one of those in the Fit Curve library. (If it is, then Nonlinear launches Fit Curve, which expects the model to be specified by name, which this script doesn't provide.) Based on your claim that the actual model is more complicated, then I took the chance that it is not in the Fit Model library and wrote this script:

```
Names Default to Here( 1 );
dlg = Column Dialog(
Title( "Nonlinear Regression" ),
yCol = Col List( "Y, Response",
Data Type( Numeric ),
Min Col( 1 )
),
xCol = Col List( "X, Predictor Formula",
Data Type( Numeric ),
Min Col( 1 ),
Max Col( 1 )
)
);
If( dlg["Button"] != 1,
Throw( "User cancelled" );
);
Remove From( dlg );
Eval List( dlg );
dt = Current Data Table();
n fits = N Items( yCol );
formula = xCol[1] << Get Formula;
n parms = N Items( Arg( formula, 1 ) );
parm = J( n fits, n parms, . );
For( f = 1, f <= n fits, f++,
nl fit = dt << Nonlinear( Y( yCol[f] ), X( xCol[1] ), Newton, Finish );
parm[f,0] = Transpose( Report( nl fit )["Parameter Estimates"][NumberColBox(1)] << Get As Matrix );
);
As Table( parm );
```

Open the JMP data table first, then open and run this script. Select all of the response columns (columns 2-82 in your example) and click **Y, Response**. Click the column with the model formula (column 1 in your example) and click **X, Predictor Formula**, . Then click **OK**.

Learn it once, use it forever!

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

Dec 12, 2016 7:34 AM
(2748 views)

Thank you!

Testing now ...

received following error upon debugging

Cannot subscript Display Box in access or evaluation of 'Subscript' , Report( nl fit )[/*###*/"Parameter Estimates"]

markbailey wrote:This solution turns out to be a bit tricky. It only works if the model you are using is NOT one of those in the Fit Curve library. (If it is, then Nonlinear launches Fit Curve, which expects the model to be specified by name, which this script doesn't provide.) Based on your claim that the actual model is more complicated, then I took the chance that it is not in the Fit Model library and wrote this script:

Names Default to Here( 1 ); dlg = Column Dialog( Title( "Nonlinear Regression" ), yCol = Col List( "Y, Response", Data Type( Numeric ), Min Col( 1 ) ), xCol = Col List( "X, Predictor Formula", Data Type( Numeric ), Min Col( 1 ), Max Col( 1 ) ) ); If( dlg["Button"] != 1, Throw( "User cancelled" ); ); Remove From( dlg ); Eval List( dlg ); dt = Current Data Table(); n fits = N Items( yCol ); formula = xCol[1] << Get Formula; n parms = N Items( Arg( formula, 1 ) ); parm = J( n fits, n parms, . ); For( f = 1, f <= n fits, f++, nl fit = dt << Nonlinear( Y( yCol[f] ), X( xCol[1] ), Newton, Finish ); parm[f,0] = Transpose( Report( nl fit )["Parameter Estimates"][NumberColBox(1)] << Get As Matrix ); ); As Table( parm );Open the JMP data table first, then open and run this script. Select all of the response columns (columns 2-82 in your example) and click

Y, Response. Click the column with the model formula (column 1 in your example) and clickX, Predictor Formula, . Then clickOK.

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

Dec 12, 2016 11:49 AM
(1364 views)

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

Dec 12, 2016 7:53 AM
(1378 views)

it errors out at this step

parm[f,0] = Transpose( Report( nl fit )["Parameter Estimates"][NumberColBox(1)] << Get As Matrix );