Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Level III

## Constrained least squares and exponential fitting

I am looking to fit Y ~ 1-exp{-[C1*(x/Xmax)^1+.......CN*(x/Xmax)^N]}. The order could be anywhere between 6 to 12 (max value of N). But before generating the fit, I need to estimate the coefficient using modified LSQ. I looked at the exponential fit (analyze fit Y-->X) and tried to enter a formulae but I do not want to directly fit the exponential curve, rather I want to estimate the best fit coefficients subect to some upper bound constraints due to the strictly monotically increasing nature of Y. . Essentially the closest I could find that represents my model  is https://www.mathworks.com/help/optim/ug/lsqlin.html . Looks like a 2 step process with the LSQ s.t. linear constraints, followed by the actual exponential fit. Not sure if there is a 2 step or a straightshot approach for the fit for a given upper bound on the C1..CN.

Any pointers would be super helpful.

Thanks,

3 REPLIES 3
Highlighted
Staff

## Re: Constrained least squares and exponential fitting

Can you linearize the relation with logs:  -Log( 1 - Y ) = c1*(x/Xmax) + c2*(x/Xmax)^2 + ... + cN*(x/Xmax)^N ?

(This way might be invalid, depending on how the errors contribute to the original expression.)

Learn it once, use it forever!
Highlighted
Level III

## Re: Constrained least squares and exponential fitting

I tried it but the estimated coefficients are off compared to some of the references I have from literature Maybe I am missing some bounds or constraints have not been entered properly. Will try again.

I also tried to add the custom model to the library as outlined here https://www.jmp.com/support/help/14-2/create-a-formula-using-the-model-library.shtml

but getting I/O error. I have admin rights not sure why this is happening. Is there any "edit" or "user input" mode that would allow me to add my nonlinear model to the library?

Highlighted
Staff

## Re: Constrained least squares and exponential fitting

The estimates will be in the log space, not the original dimensions. Would that difference account for the unexpected results? Also, these results were not intended to be the best estimates but serve only as the initial values for the parameters before fitting the data with the Nonlinear platform. You must back-transform the starting values with Exp() function.

I don't know about I/O error. Is it possible that the script file is locked?

I suggest making your custom model manually / interactively first. That is, define the model first as a column formula. This way will demonstrate that such a model is feasible. The Model Library is only one way to fit a custom model. It is not required. This way will also provide the correct expression if you decide later to include it in the Model Library.

Learn it once, use it forever!
Article Labels

There are no labels assigned to this post.