Message Boards Message Boards

0
|
4965 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Regress multiple data with multiple functions?

Posted 6 years ago

The confidence interval is obtained by using command such as "NonlinearRegress". In my problem, I need to fit data1 with function f(k1, p1, k3, p3), and fit data2 with function f(k2, p2, k3, p3), finally get (k1, p1, k2, p2, k3, p3) with their confidence intervals...but if I use "NonlinearRegress", I can only fit one data at a time, for example

NonlinearRegress[data1, f(k1, p1, k3, p3)]

or

NonlinearRegress[data2, f(k2, p2, k3, p3)]

... then, k3 and p3 are not unique. So how to fit two data with two functions that share some same parameters, and then get confidence intervals? Thanks!!

POSTED BY: Nan Yang
3 Replies
Posted 6 years ago

Thank you very much! Your method is very effective for my question and good for NonlinearRegress!!

Best,

YN

POSTED BY: Nan Yang
Posted 6 years ago

You must be using a very old version of Mathematica:

As of Version 7.0, NonlinearRegress has been superseded by NonlinearModelFit and is part of the built-in Wolfram Language kernel.

What version are you using? Also your example doesn't match the syntax for NonlinearRegress. Including a minimal working example would be helpful.

The following will work for NonlinearModelFit (and possibly for NonlinearRegress). Combine the two datasets and include a new column identifying the dataset and then use the Boole statement:

data = Join[Insert[#, 1, 1] & /@ data1, Insert[#, 2, 1] & /@ data2]
nlm = NonlinearModelFit[Boole[id==1] a1 + Boole[id==2] a2+ b x, {a1,a2,b}, {id,x}]
nlm["BestFitParameters"]
POSTED BY: Jim Baldwin
Posted 6 years ago

Is that the thing Mathematica can't do?

POSTED BY: Nan Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract