cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
eugur
Level I

Parameter bound for Nonlinear curve fitting

I'm trying to fit to data points for 1000+ samples. I've found out that Biexponential 5P function gives the best fitting results. However, same samples with one or two data points slightly outside of the trend makes the fitting really strange. For typical population, decay rate parameters are around 0.2 and for those samples fitting provides results in the range of 10. "Parameter bound" and increased iteration limit options in nonlinear fitting resolves the issue. However, doing this manually through GUI is impossible. 

 

Is there a way to set parameter bounds and iteration number "globally" (for all samples)?


I also tried script option, but I'm not familiar with JSL scripting and I couldn't achieve to show fit results with the script below.

<JSL> 

Names Default To Here( 1 );

dt = Current Data Table();


obj = Nonlinear( Y( :data ), X( :data Predictor ), By( :ID ) );
obj << Go;
obj << Parameter Bounds(
	asympt( 14, 22 ),
	scale1( 0, 100 ),
	decayrate1( -0.2, 0.1 ),
	scale2( -100, 0 ),
	decayrate2( -0.2, 0.1 )
);
obj << Iteration Limit( 10000 );
obj << Finish;
G = obj << Get Estimates;
Show( G );
obj << Report View( "Summary" );

obj << get estimates;

Note: Original JSL moved into JSL display box by txnelson 
<JSL>

8 REPLIES 8

Re: Parameter bound for Nonlinear curve fitting

Hi @eugur ,

 

I'm going to show you how to achieve this without using JSL just so you understand how the process works (apart from the starting section). So you should start by generating a formula column that is going to provide the blank parameter values that can then be changed to find the best fit for your data in the Non-linear platform. First off you want to create the formula column (i've added a brief script here for this, but you can also do it by hand):

 

dt=current data table();
dt<<New Column("BExp 5P Formula",Formula(
			Parameter(
				{a = 0, b = 0, c = 0, d = 0, f = 0},
				a + b * Exp( -c * :Day ) + d * Exp( -(f * :Day) )
			)
		));
		

When that's ready, open up the non-linear platform, put your formula column in the "X, Predictor Formula" role, and your Y of interest in the Y section, hit Run. When the platform has booted up, click the red button and select 'parameter bounds' and put in the limits that you wish to use -

Ben_BarrIngh_0-1749874842390.png

Ben_BarrIngh_1-1749874859915.png

 

You can then run the Non-linear platform with 'Go' to get the paramaters estimated with those bounds.

 

Hope that helps!

Thanks,

Ben

 

 

“All models are wrong, but some are useful”
eugur
Level I

Re: Parameter bound for Nonlinear curve fitting

Hi Ben,

Thank you for your response, but I can already do this and this is not what I'm asking for. As I mentioned in my post, I'm trying to fit to data points for 1000+ samples, which means 1000+ curves fitted. Therefore, in non-linear platform, I would also need to use "ID" column in "By" section. (Somehow "Group" option doesn't work here while it works for Fit Curve).

 

When you have multiple samples, you need to do what you explained (click the red button and select 'parameter bounds' and put in the limits that you wish to use) manually for each sample. This might be fine if you have a couple samples, but not for 1000+. What I'm asking is to be able to set parameter bounds and number of iterations for all 1000+ samples at once. 

Re: Parameter bound for Nonlinear curve fitting

Hi @eugur ,

 

If you're not using the group term, then the parameter bounds that are set are being set globally for all 1000+ samples, (also the reason grouping doesn't work in Non-linear is because the group itself has to be integrated into the prediction formula you are feeding NL with).  The script you have should work, but you don't need to run 'Go' on the second line, that's why the parameter bounds aren't being added because the platform is running before anything can be changed. Here's an example which then uses the 'combined data table' tool to get a singular report to easily see how the values have changed in each sample

 

dt=current data table();

id_no=N Items(Associative Array(dt:Batch)<<get keys;);//grab how many samples exist that you want to individually run NL on

dt<<New Column("BExp 5P Formula",Formula(
			Parameter(
				{a = 0, b = 0, c = 0, d = 0, f = 0},
				a + b * Exp( -c * :Day ) + d * Exp( -(f * :Day) )
			)
		));
		

NLplatform=DT<<Non Linear(
	Y (:Rel Potency),
	X (:"BExp 5P Formula"n),
	By (:Batch)
	);
NLplatform<<iteration limit(1000);
NLplatform<<
	Parameter Bounds( a( 10, 30 ), b(1,9), c(4,10), d(10,200),f(6,1000) );

NLPlatform<<Go;
NLPlatform<<Finish;

//Instead of using Get Estimates, have a combined table appear that is more organised
Estimate_dt=report(NLPlatform[1])["Solution",Tablebox(2)]<<make combined data table; //use this to grab all of the estimates into one data table, you need to refer to any of the sub-reports created with the 'by' variable for NLPlatform [x] where x is the number of a report

 

 

“All models are wrong, but some are useful”
eugur
Level I

Re: Parameter bound for Nonlinear curve fitting

Thanks Ben, 
This functionally works. But I think nonlinear platform uses a different solver. Almost 50% of the fit results are not acceptable.

Re: Parameter bound for Nonlinear curve fitting

Hi @eugur , you can try widening your iteration limit or even consider using an SSE grid to see if it's even possible to obtain suitable parameter values for your samples - you might also want to consider running different iterations from the 'Netwon' option that is used as default.

 

The reason 50% of the results are failing individually is because when all samples are used the effect on overall SSE model fit is reduced so the likelihood of a single point causing failure is reduced, whereas when it's just one single point being analyzed then failure is more likely.

“All models are wrong, but some are useful”

Re: Parameter bound for Nonlinear curve fitting

Fit Curve works best for cases with many curve ID's, but if your fitting function is not included in Fit Curve's library of pre-programmed functions, then Fit Nonlinear is needed. 

As you noticed, "Group" works differently in Fit Nonlinear and is not what you want to use in this case. I recommend grouping the curves using "By". 

I prefer using the following syntax for this. Could you try this and let us know if it works:

Nonlinear(
	Y( :data ),
	X( :data predictor),
	By( :ID ),
	Parameter Bounds(
		asympt( 14, 22 ),
		scale1( 0, 100 ),
		decayrate1( -0.2, 0.1 ),
		scale2( -100, 0 ),
		decayrate2( -0.2, 0.1 ) ),
	Iteration Limit( 10000 )
); 
eugur
Level I

Re: Parameter bound for Nonlinear curve fitting

Hi Christian,

Thank you very much for your response. You are right, Fit Curve seems to work much better. The fitting function I'm using (Biexponential 5P) is included in Fit Curve's library of pre-programmed functions. However, as I mentioned previously, for same samples (5%) the fitting results is really strange and that's the reason I wanted to try Fit Nonlinear option. But even with the boundaries, Fit Nonlinear can only fit around 50% of the samples accurately. 

So my questions are:
- Is it possible to add Parameter Bounds for Fit Curve?
- If not, is it possible to use same solvers and settings for Fit Nonlinear as in Fit Curve?

Re: Parameter bound for Nonlinear curve fitting

Hi eugur,

1) Fit Curve does not support Parameter Bounds as far as I know. 2) Fit Curve uses a different algorithm from Nonlinear, so the same solver cannot be used. 

Fit Curve and Fit Nonlinear look similar on the surface, but they are actually quite different "under the hood". Nonlinear is a traditional nonlinear least squares regression solver. It has maximum flexibility, but also requires the most manual input. Nonlinear regression fitting, unlike linear regressions, is non-deterministic, so there is no guarantee that a given set of initial guesses will always converge, even for "similar" datasets. This is not specific to JMP; in my experience most nonlinear solvers require occasional manual "tuning", which makes batch processing of hundreds of datasets an interesting challenge (but not impossible!). That's where JMP's Fit Curve platform comes in. 

Fit Curve is a special case with a small library of optimized pre-set functions. It does not use a fully general nonlinear regression solver, instead each function uses a special algorithm custom-written for that function. This makes it exceptionally fast and more likely to converge for a wide variety of data. (I am not a software developer nor a mathematician so please forgive the nontechnical explanation, this is just my basic understanding!). As far as I know, Fit Curve does not support parameter bounds, perhaps because they are usually not needed. If you find that parameter bounds are required for your situation, then we are back to using the Nonlinear platform. Ben proposed some good ideas and there are other things to try using Nonlinear+scripting if Fit Curve doesn't work--but my suggestion is always to try Fit Curve first, and only use Fit Nonlinear as a backup option if that doesn't work. 

Here are some links that might be interesting: 

Example of Setting Parameter Limits

Statistical Details for Fit Curve Models

nonlinear vs fit curve giving different results? - JMP User Community

-Christian 

Recommended Articles