Code covered by the BSD License  

Highlights from
Multiple curve fitting with common parameters using NLINFIT

4.5

4.5 | 2 ratings Rate this file 29 Downloads (last 30 days) File Size: 2.41 KB File ID: #40613
image thumbnail

Multiple curve fitting with common parameters using NLINFIT

by

 

Wrapper for NLINFIT which allows simultaneous fitting for multiple data sets with shared parameters.

| Watch this File

File Information
Description

This function allows you to simultaneously fit multiple data sets (for example noisy measurements) with multiple models, which share some (or all) of the fitting parameters.

Unlike difference approaches using fminsearch (or similar functions), this submission wraps around NLINFIT and thus allows immediate estimation of confidence intervals on data predictions and fitted parameters.

PLEASE NOTE: In this implementation, different data sets are weighted according to their relative lengths. Special care should be taken when those lengths are considerably different from one another to avoid biased results towards one data set in particular.

Required Products Statistics Toolbox
MATLAB
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
20 Nov 2014 Luis Cerdan

Dear Chen: To make it work, even with the example your provided, I had to remove the output arguments "errorparam" and "robustw", as otherwise nlinfit gave an error (Too many output arguments). Once remove the program worked fine for my needs.

20 Nov 2014 Luis Cerdan  
19 Feb 2014 Kevin  
19 Sep 2013 Chen

You are always free to do the wrapping manually, yourself. I found that I routinely need to perform this task of multiple fitting, and was tired of writing code every time for different models, and came up with this solution. I hope it will help and save time to others as it did for me.

19 Sep 2013 Matt J

OK, sorry, I didn't see that the parameters were shared.

I wonder, though, why it wouldn't be better to just manually write an mfile for the combined modelfun, instead of auto-wrapping several separate anonymous model functions into one big anonymous function?

You obviously don't intend this for wrapping a large number of model functions and data sets. The nesting of many anonymous functions would make it very slow. Conversely, for a small number of data sets, manually wrapping the problems together should be pretty easy.

19 Sep 2013 Chen

Matt: I don't understand how a for-loop would enable you to fit multiple data sets with COMMON estimation parameters.

19 Sep 2013 Matt J

I would be surprised if this were faster than a for-loop. If I'm wrong, it might be worthwhile to add some demo files showing the advantage of the wrapping.

Contact us