5

I have a LogLog plot, and i'm unsure about how to fit a line to it. The data represents a calibration curve.

 calibdata = {{1, 39270.4}, {0.01, 4982.57}, {0.001, 1153.55}}
 ListLogLogPlot[calibdata, PlotMarkers -> {Automatic, Medium}]
olliepower
  • 2,254
  • 2
  • 21
  • 34

2 Answers2

6

There a number of approaches. This is a start (amplifying Kuba's comment):

lm = LinearModelFit[Log10@calibdata, {1, x}, x];
param = lm["ParameterTableEntries"]
coeff = First@Transpose@param
fun[x_] := 10^#1 x^#2 &@@ coeff

The parameters:

{{4.6208, 0.0963769, 47.945, 0.0132762}, {0.501766, 0.046298, 10.8378,
   0.0585751}}

Note the linear relationship is of borderline significance (slope coefficient is second row with p-value as last entry of this row). You can display the formatted table using lm["ParameterTable"].

The coefficient (point estimates):

{4.6208, 0.501766}

The power law fit can be displayed:

fun[a]

yields:

41763.4 a^0.501766

Visualizing fit:

enter image description here

Show[p1, LogLogPlot[fun[x], {x, 0.001, 1}]]

where p1 is original ListogLogPlot.

You can explore other "diagnostics" and standard errors (will need to be back transformed) for prediction bands (try lm["Properties"] or whatever you name you model object and review documentation: LinearModelFit)

ubpdqn
  • 60,617
  • 3
  • 59
  • 148
1
calibdata = {{1, 39270.4}, {0.01, 4982.57}, {0.001, 1153.55}};
fit = LinearModelFit[Log10@calibdata, x, x];
% // Normal

4.6208 + 0.501766 x

Plot[Normal@fit, {x, -4, 1}, Axes -> False, Frame -> True, 
                             Epilog -> {PointSize@.02, Point@Log10@calibdata}]

enter image description here

Kuba
  • 136,707
  • 13
  • 279
  • 740