0
$\begingroup$

I have five data sets, {4.88281 10^(-5), 0.0788}, {9.76563 10^(-5), 0.1014}, {0.000195313, 0.12455}, {0.000390625, 0.15594}, {0.0015625, 0.18587}. I was using EXCEL to add the trendline, but the x intercept is a negative value. I wanted to fit the trendline close to zero but don't include (0,0) in my plot, can I get this done with Mathematica?

Thanks!

$\endgroup$
2
  • $\begingroup$ You need to specify a model. I suspect you want $y=a+b*\log x + \epsilon$ where $\epsilon \sim N(0,\sigma^2)$. If so consider LinearModelFit or NonlinearModelFit. $\endgroup$
    – JimB
    Jul 23, 2020 at 21:20
  • $\begingroup$ In FindFit[data,{expr,cons},pars,vars] , you can add a constraint. $\endgroup$
    – flinty
    Jul 23, 2020 at 21:28

1 Answer 1

1
$\begingroup$
data = {{4.88281 10^(-5), 0.0788}, {9.76563 10^(-5), 0.1014}, {0.000195313, 0.12455},
  {0.000390625, 0.15594}, {0.0015625, 0.18587}};

lm = LinearModelFit[data, Log[x], x]
Show[ListLogLinearPlot[data], 
 LogLinearPlot[lm[x], {x, Min[data[[All, 1]]], Max[data[[All, 1]]]}]]

Data and fit with x on log scale

Show[ListPlot[data], 
 Plot[lm[x], {x, 0, Max[data[[All, 1]]]}, PlotRange -> All]]

Data and fit

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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