Message Boards Message Boards


Regress multiple data with multiple functions?

Posted 10 months ago
3 Replies
1 Total Likes

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)]


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!!

3 Replies
Posted 10 months ago

Is that the thing Mathematica can't do?

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}]
Posted 10 months ago

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



Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract