Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to do Linear regression on a Log-Log graph?

Subject: how to do Linear regression on a Log-Log graph?

From: LISHAN RAN

Date: 24 Aug, 2010 04:45:06

Message: 1 of 3

Hello,

I have 2 variables (precipitation and temperature) and plot them on a Log-Log axes using matlab, now I want to use linear regression method to calculate the slope (the change rate of precipitation with increasing temperature). So I use the ezyfit toolbox to fit the plots, but I could not get a straight line but rather a curve. Could someone help how to do a linear regression on a Log-Log plot? Thanks a lot in advance!

Subject: how to do Linear regression on a Log-Log graph?

From: Rogelio

Date: 24 Aug, 2010 06:14:08

Message: 2 of 3

"LISHAN RAN" <ranlishan@gmail.com> wrote in message <i4vioi$qcu$1@fred.mathworks.com>...
> Hello,
>
> I have 2 variables (precipitation and temperature) and plot them on a Log-Log axes using matlab, now I want to use linear regression method to calculate the slope (the change rate of precipitation with increasing temperature). So I use the ezyfit toolbox to fit the plots, but I could not get a straight line but rather a curve. Could someone help how to do a linear regression on a Log-Log plot? Thanks a lot in advance!

What do you mean by a log-log plot? are transforming your variables to log scales? let say that x = precepitation and y = temp, so g = log(x) and p = log(y) and it is g and p what you are plotting and what you want to do a regression analysis? it this is the case, then you need to use 'regress' function in matlab. you will need to specify your design matrix, and remember to include your vector of ones in it (i believe that you would like to include the intercept). then you will need to plot a scatter graph of g and p and over impose the fitted line given by the coefficients in 'regress'. You find many example of how to use 'regress' in the help browser of matlab.

Subject: how to do Linear regression on a Log-Log graph?

From: Richard Willey

Date: 24 Aug, 2010 12:46:41

Message: 3 of 3

Hi

The Statistics Toolbox product page has a nice demo titled "Pitfalls in
Fitting Nonlinear Models by Transforming to Linearity".

http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/xform2lineardemo.html

The demo includes a nice applied example showing how to perform a log
transform. It also includes discussion about some problems that might occur
when you are using these techniques.

regards,

Richard


"LISHAN RAN" <ranlishan@gmail.com> wrote in message
news:i4vioi$qcu$1@fred.mathworks.com...
> Hello,
>
> I have 2 variables (precipitation and temperature) and plot them on a
> Log-Log axes using matlab, now I want to use linear regression method to
> calculate the slope (the change rate of precipitation with increasing
> temperature). So I use the ezyfit toolbox to fit the plots, but I could
> not get a straight line but rather a curve. Could someone help how to do a
> linear regression on a Log-Log plot? Thanks a lot in advance!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us