Hello All,
I want to perform a fit to a data set in order to obtain the model parameters which best fits the data. Moreover I added a value (coming from the experiment) for each of the parameters as a fit constraint. Until here nothing special, but what I want to incorporate now is the correlation between the parameters as an additional constraint of the fit. Anybody knows how to do so?
Attached the code of a simple example inlcuding the values of the parameters to be fitted as a constraint but without including the correlation between them which is precisely what I want to do/incorporate in my new fit.
data = {{0, 1.02}, {0.5, 2.2}, {1, 3.1}, {1.5, 3.7}, {2,
4.85}, {2.5, 6.3}, {3, 7.25}, {3.5, 8.4}, {4, 8.75}, {4.5,
9.5}, {5, 11.25}}
aexp = 0.98; bexp = 2.1;
datafit = Join[data, {{11, aexp}}, {{12, bexp}}]
dataweights = {0.1, 0.2, 0.1, 0.15, 0.25, 0.21, 0.12, 0.08,
0.1, 0.15, 0.075}
aexperr = 0.01; bexperr = 0.025;
dataweightsfit = Join[dataweights, {aexperr}, {bexperr}]
F[a_, b_, x_] := a + b*x
ModelFit[a_, b_, x_] :=
If[x < 10, F[a, b, x], If[10 < x < 11.5, a, b]]
FitFunction2 =
NonlinearModelFit[datafit, ModelFit[a, b, x], {a, b}, x,
Weights -> dataweightsfit^-1]
FitFunction2["BestFitParameters"]
{a -> 0.987645, b -> 2.02411}
Many thanks in advance.
All my best,
Sergi