Message Boards Message Boards

Regress multiple data with multiple functions?

GROUPS:

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
Answer
1 month ago

Is that the thing Mathematica can't do?

POSTED BY: Nan Yang
Answer
27 days 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
Answer
26 days ago

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

Best,

YN

POSTED BY: Nan Yang
Answer
21 days ago

Group Abstract Group Abstract