This is certainly answered in another elsewhere on the site, but I can't find a simple example.
1. Ensure proper formatting
If you wish to have your experimental data in the symbols x
, y
, and z
, then these symbols cannot show up in your model. Adjust the model slightly such as this:
x = {1, 1, 1, 2, 2, 2}
y = {1, 2, 3, 1, 2, 3}
z = {1, 2, 3, 4, 5, 6}
w = {.531, .341, .163, .641, .713, -0.040}
model = x1^a + (b x1^2)/y1 + c y1 z1
Also make sure that your numbers are interpreted as numbers by Mathematica. The last term in w
needs to be fixed.
2. Follow the documentation
The documentation for NonlinearModelFit
is pretty good and provides you with examples as well as the summary statistics that can be easily extracted after the fitting is complete.
NonlinearModelFit
wants the data entered in the format {{xi, yi, zi, wi}, {...},...} which can be achieved easily with Transpose
nlm = NonlinearModelFit[Transpose[{x,y,z,w}],model,{a,b,c},{x1,y1,z1}]
3. View Results
By assigning NonlinearModelFit
to a symbol, you can easily access summary statistics as well as the information in which you are interested:
nlm["BestFitParameters"]
nlm["ParameterTable"]
NonlinearModelFit
will help you out. You have to take care with your symbol definitions, though, if the data you are passing toNonlinearModelFit
is in the symbolx
, then the value should not also be called x. $\endgroup$