# Find Fit error 4P logistic

I am trying to fit a four parameter logistic curve to my data set. I have the estimated values for each coefficint, but it says the jacobian is not a matrix...

Here is my data:

xydata = {{1000,18},{750,65},{500,67},{200,101},{100,88},{50,91},{25,86},{0,92}}

model = (a1 - a2)/(1 + (x/x0)^p) + a2

FindFit[xydata, model, {{a1, 93}, {a2, -2}, {x0, 800}, {p, 4}}, x]


Any suggestions? Thanks!

• Trying to find a non-integer power p with FindFit worries me. If I assign p=4 and FindFit the rest it instantly finds good fits for the other three variables. If clear the assignment of p and use those better estimates to try to find all four variables then it doesn't complain about finding these, but I am still skeptical about using FindFit this way.
– Bill
Jan 12 at 4:29

## 1 Answer

There are several (non-Mathematica) issues. You only have 8 data points to estimate 5 parameters (a1, a2, x0, p, and the error variance). The model is essentially overparameterized.

Changing the model to allow for x = 0 and adding in MaxIterations->1000 gets a "result":

xydata = {{1000, 18}, {750, 65}, {500, 67}, {200, 101}, {100, 88}, {50, 91}, {25, 86}, {0, 92}};
model = (a1 - a2)/(1 + If[x == 0, 0, (x/x0)^p]) + a2
ff = FindFit[xydata, model, {{a1, 93}, {a2, -2}, {x0, 800}, {p, 4}}, x, MaxIterations -> 1000]
(* {a1 -> 90.7083, a2 -> -4.19539*10^7, x0 -> 175708., p -> 2.57191} *)


This will give you an equation that will give a plausible fit.

However, you should avoid FindFit as it doesn't give you any diagnostics. Use NonlinearModelFit instead:

nlm = NonlinearModelFit[xydata, model, {{a1, 93}, {a2, -2}, {x0, 800}, {p, 4}}, x, MaxIterations -> 1000];
nlm["BestFitParameters"]
(* {a1 -> 90.7083, a2 -> -4.19539*10^7, x0 -> 175708., p -> 2.57191} *)


Now you can look at some diagnostics:

(* Parameter correlation matrix *)
nlm["CorrelationMatrix"] // MatrixForm


(* Rank of parameter covariance matrix *)
MatrixRank[nlm["CovarianceMatrix"]]
(* 2 *)


These diagnostics (and maybe the estimated values of a2 and x0) suggest that you have an overparameterized model. The result reasonably reproduces the data but you certainly shouldn't attempt to interpret the values of the parameters - either their absolute value or sign.

Solutions? (1) Get more data if you can. (2) Don't bet the farm on the results.

• Ok that makes sense, thanks! Jan 12 at 20:56