3
$\begingroup$

I am trying to fit my data to the function: a + (b*(c/2)^2)/((T - d)^2 + (c/2)^2)

I entered nlm = NonlinearModelFit[data, a + (b*(c/2)^2)/((T - d)^2 + (c/2)^2), {a, b, c, d}, T]

However it returned [0.747-533.437/(260.512+<<1>>^2)]

How can I know the best fit value of each parameter?

data = {{1., -0.58}, {2., -1.507}, {3., -0.932}, {4., -0.3}, {5., \
-1.531}, {6., 0.193}, {7., 
   0.873}, {8., -0.697}, {9., -0.147}, {10., -0.114}, {11., -0.172}, \
{12., -1.847}, {13., 0.636}, {14., -0.846}}/
nlm = NonlinearModelFit[data, 
  a + (b*(c/2)^2)/((T - d)^2 + (c/2)^2), {a, b, c, d}, T]
$\endgroup$
3
  • 2
    $\begingroup$ You need to post complete reproducible code with data (at least sample). $\endgroup$ Commented Jan 21, 2023 at 4:09
  • $\begingroup$ Welcome to Mathematica SE. To start: 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, since the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) consider accepting the answer, if any, that solves your problem, by clicking checkmark sign, 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bmf
    Commented Jan 21, 2023 at 4:09
  • 1
    $\begingroup$ Thanks for the reproducible code. Just use nlm["BestFitParameters"] or better yet nlm["ParameterTable"] which also gives you measures of precision for each parameter. But don't be discouraged if the question is closed as these are available in the online documentation. $\endgroup$
    – JimB
    Commented Jan 21, 2023 at 4:46

1 Answer 1

4
$\begingroup$

While, @JimB left a valuable comment, I think that the following is much easier in this case.

data = {{1., -0.58}, {2., -1.507}, {3., -0.932}, {4., -0.3}, {5., \
-1.531}, {6., 0.193}, {7., 
   0.873}, {8., -0.697}, {9., -0.147}, {10., -0.114}, {11., -0.172}, \
{12., -1.847}, {13., 0.636}, {14., -0.846}}
nlm = NonlinearModelFit[data, 
  a + (b*(c/2)^2)/((T - d)^2 + (c/2)^2), {a, b, c, d}, T]

then you do

Normal[nlm]

output

These are the same values that you would get from the suggestion in the comment.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.