drakislow
drakislow

Reputation: 41

Why Cant Get Linear Regression Line on Logarithmic Scale

I’ve tried to Math.NET C# Fit.Line function with the aim of finding the linear regression model based on some data. The result is proper with the regression method but not seeming as a stright on logarithmic scale. I’m working on logarithmic scale and my question is that how can I get the straight model on a logarithmic scale?

My example is here:

double[] xdata = new double[] { 10, 20, 30 };
double[] ydata = new double[] { 15, 20, 25 };

Tuple<double, double> p = Fit.Line(xdata, ydata);
double a = p.Item1;
double b = p.Item2;

If the values will be displayed on a logarithmic scale, there could not be get any linear straight line, it seems to curve more. and I would like to show linear regression ax+b as a straight

Upvotes: 0

Views: 1760

Answers (1)

James Phillips
James Phillips

Reputation: 4657

Here is a visual illustration of the comment from @EricLippert showing the exact same "y = ax + b" straight line plotted in different ways. First, standard linear scaling, where the regression line appears straight:

standard_scaling:

Now the exact same plot, but with with Y axis as log scaling:

log_y

And here with log X scaling:

log_x

And finally with both axes log scaled:

log_log

Upvotes: 1

Related Questions