Now I am trying to fit some data with a implicit model function.
Firstly, I tried a toy example.
Toy example with input and output
data = {{1, 1}, {2, 1.4}, {3, 1.8}, {4, 2.4}, {5, 2.9}};
fitfunc[a_,b_,x_] := y /. FindRoot[a y + b Log[y] == x, {y, 1}];
FindFit[data, fitfunc[a, b, x], {a, b}, x]
Mathematica gives the following warning message and answer:
FindRoot::nlnum: The function value {0. +1. a-1. x} is not a list of numbers with dimensions {1} at {y} = {1.}. >>
ReplaceAll::reps: {FindRoot[a y+b Log[y]==x,{y,1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
{a -> 0.986636, b -> 1.96879}
The fit seems good.
Show[ListPlot[data], ContourPlot[Evaluate[a y + b Log[y] == x /. %], {x, 1, 5}, {y, 1, 4}]]
The fit result:
I have read the documentation of Symbolic Evaluation, and tried to use NumberQ in the function declaration, but I got the same warning message.
What am I doing wrong and how to solve this problem to avoid the warning message?