Docsity

Linear Regression Tutorial: Analyzing Frog Croaking Rates with MATLAB, Slides of Computational Methods

Partial preview of the text

Download Linear Regression Tutorial: Analyzing Frog Croaking Rates with MATLAB and more Slides Computational Methods in PDF only on Docsity!

Linear

Regression

Tutorial

The MATLAB code

% Plot Regression Line Tfmax = max(Tf); Tfmin = min(Tf); Tfplot = linspace(Tfmax, Tfmin); % Calc CpH projected response using Regression Constanstants CpHplot = m0Tfplot + b0; plot(Tf, CpH,'', Tfplot, CpHplot), xlabel('T °F'), ylabel('CpH (Croaks/Hr)'),... Title('Frog Croaking vs Temperature'), grid % disp('Diplaying °F Regression Plot - Hit any key to continue ') pause % % Calc Goodness of Fit %% the Minimized J value, J J0 = sum((m0*Tf+b0-CpH).^2) %% Calc Sum of Sqs about the Mean CpH_avg = mean(CpH) S = sum((CpH-CpH_avg).^2) %% Calc r-sqd r_sqd = 1-J0/S; % % disp('Coeff of Determination, r-sqd = ') disp(r_sqd)

The Regression Plot

T °F

CpH (Croaks/Hr)

Frog Croaking vs Temperature

By Excel

  • Use to Check m0, b0, and r

2

Frog Croaking

CpH = 0.2157•Tf - 0. R^2 = 0.

15

16

17

18

19

20

70 75 80 85 90 95 Temperature (°F)

Croak Frequency (Croaks per Hour)

E25_Lin_Regress_Tutorial_0703.xls