I would like to write the following statement:
data2fit = NonlinearModelFit[data2, {a Sqrt[b x + c] + d, b x + c > 0}, {a, b, c, d}, {x}]
However, it returns unevaluated. Without the constraint, I get something like:
NonlinearModelFit::nrnum: The function value-1.86156*10^15+1.42765*10^13 Iis not a real number at{a,b,c,d} = {-145129.,1.,-739.575,-14092.9}.>>
It doesn't seem to like the fact that there is a constraint that includes the independent variable x. The fit can be made to work if I use Abs[b x + c] in the model, but that's not really the same thing.
Is there a good way to specify this type of constraint?
Sqrt[Max[b x + c, 0]]work? If not, can you share your data? I also wonder if making good guesses at the final values would help avoid the errors. – JimB Jan 02 '16 at 03:15NonlinearModelFit[data2, {a Sqrt[b x + c] + d, b Min[data2[[All, 1]]] + c > 0}, {{a, 1}, {b, 0.5}, {c, 1}, {d,1}}, {x}]while making sure that the initial values satisfy the constraint? In other words replacexin the constraint withMin[data2[[All,1]]]. – JimB Jan 02 '16 at 03:41a,b, andcare very strongly correlated with one another. Recovering meaningful values for them may be difficult unless there are other constraints to guide the process. – Oleksandr R. Jan 02 '16 at 04:09a Sqrt[x + c] +danda Sqrt[b x + 1] + dare equivalent models. There are really only two parameters to fit. – JimB Jan 02 '16 at 05:23