lecture 5 curve fitting by iterative approaches marine qb iii marine qb iii modelling aquatic rates...

35
Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 1 School of Biological Sciences, University of Liverpool School of Biological Science

Post on 21-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Lecture 5Curve fitting by iterative approaches

MARINE QB IIIMARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471

© 2001 School of Biological Sciences, University of Liverpool

School of

Biological Sciences

School of

Biological Sciences

Page 2: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting: the iterative approach

Ing

esti

on

Prey 0

Hc =k+ H

HmaxH

Page 3: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Linear Functions General linear equations

Any straight line can be represented by the general linear equation

y = mx + c

y1

x1

y2

or (y1 +y)

y (y2 - y1)

x2 or (x1 +x)

x (x2 - x1) Slope (m) (y/ x)Intercept (c)

Origin

00

Y = a + bX

a

b

Page 4: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

X is the independent variable since its value is freely chosen

X

Y is the dependent variable since its value depends on x

Y

0 1 2 3

15

30

45

Regression Analysis

Y = a + bX

Page 5: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Often X may be thought of as the cause and Y as the effect of that cause

0 1 2 3

15

30

45

Hei

ght

clim

bed

cause (C)

effe

ct (

E)

Regression Analysis

E = a + bC

Page 6: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Some basic algebra

bXaY Remember the equation of a straight line:

However when doing regression analysis, this becomes a statistical model

The model is a way of estimating values of Y, given a value of X and the constants a and b

But Y is estimated. Therefore:

Where a is the Y-intercept, and b the slope

b is also called the regression coefficient

bXaY

Page 7: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Model 1 Regression Analysis

In Model 1 Regression

X is measured without error

X measurements are independent

X is under the control of the investigator

For a value of X there is a population of Y-values, which are normally distributed

There is equal variance of Y at each X value

X

Y

Note, in Model 2 regression both X and Y are random variable – we will not be discussing this

Page 8: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

The figure now shows the line of best fit

The line is a model of the relationship between X and Y

We have selected our subjects with known values of X and then measured Y

X

Y

The line of best fit

Page 9: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

The line of best fit

How do we select the line of best fit?

We expect it to pass through (X,Y )…

For any line, we could calculate the vertical deviations of each point from that line

XX

Y

Y

Page 10: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

How do we select the line of best fit?

We expect it to pass through (X,Y )…

For any line, we could calculate the vertical deviations of each point from that line

Squaring the deviations makes them positive

Summing them gives the sum of the squares of the deviations

XX

Y

Y

22 YYd

The line of best fit

The line of best fit will minimise d 2

Page 11: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

22 YYd

Now we can write the regression equation

22 bXaYd

bXaY

By definition

The regression equation is

By substitution

XbYa

22 XXn

YXXYnb

Calculating values of a and b

bXaY

We need to obtain values of a and b that give minimum value of this expression for sum of squares of deviations from the fitted line

We solve this with differential calculus

To obtain

Then

Page 12: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Calculating the line of best fit

That was one method of finding the line of best fit, called least squares regression

It works because, using calculus we can solve for b

However, there are some equations (non-linear ones) that we cannot solve this way

Instead we use another method: Iterative fitting

X

Y

Page 13: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Here are the steps:1. make an estimate of the

parameters, in this case, the slope (b) and the intercept (a)

2. Calculate the sum of squares of deviations from the fitted line

X

Y

22 YYd

The line of best fit by iteration

3. Record this value, and then try another pair of estimates of a and b

Page 14: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Here are the steps:1. make an estimate of the

parameters, in this case, the slope (b) and the intercept (a)

2. Calculate the sum of squares of deviations from the fitted line

3. Record this value, and then try another pair of estimates of a and b

4. Calculate the sum of squares… repeat until you obtain the smallest sum of squares you can get

5. When the sum of squares is minimal, this is the best fit

X

Y

The line of best fit by iteration

22 YYd

Page 15: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

This process may seem very labourious, but computers make it possible

Steps1. Look at the data and

think about it2. Decide if you need non-

linear regression3. Pick a mathematical

model4. Choose initial parameter

values (although some programes do this for you)

5. Fit the curve to the data

X

Y

The line of best fit by iteration

bXaY

Page 16: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

The line of best fit by iterationYou must satisfy these

assumptions for iterative-fitting

1. X is measured without error 2. X is under the control of the

investigator 3. X values are independent of

each other 4. For a value of X there is a

population of Y-values, which are normally distributed

5. There is equal variance of Y at each X value

X

Y

Page 17: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

The line of best fit by iterationNext, ask yourself the following questions1. Does the curve go through the data (if you

pick the wrong initial parameters it can all go pear-shaped)?

2. Are the best-fit parameters plausible (see above)?

3. How precise are the best-fit parameters (we will learn about how to calculate precision in a minute)?

4. Would another model be more appropriate?

5. Have you violated any of the assumptions for iterative-fit regressions?

Page 18: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using Follow these steps1. Open SigmaPlot 8.0

Page 19: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 20: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using SigmaPlot 8.0Follow these steps1. Open SigmaPlot 8.02. Enter data into spread sheet (our data set

will be a functional response)

Page 21: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 22: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using SigmaPlot 8.0Follow these steps1. Open SigmaPlot 8.02. Enter data into spread sheet (our data set

will be a functional response)3. Make a graph

Page 23: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 24: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using SigmaPlot 8.0Follow these steps1. Open SigmaPlot 8.02. Enter data into spread sheet (our data set

will be a functional response)3. Make a graph4. Click on the data

Page 25: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 26: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using SigmaPlot 8.0Follow these steps1. Open SigmaPlot 8.02. Enter data into spread sheet (our data set

will be a functional response)3. Make a graph4. Click on the data5. In the “statistics” drop down menu, chose

“regression wizard”

Page 27: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 28: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological

Curve fitting using SigmaPlot 8.0Follow these steps1. Open SigmaPlot 8.02. Enter data into spread sheet (our data set

will be a functional response)3. Make a graph4. Click on the data5. In the “statistics” drop down menu, chose

“regression wizard”6. Choose “hyperbola” in the “equation

category”7. Choose “2-paramerter” in the “equation

name”

Page 29: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 30: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 31: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 32: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 33: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 34: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological
Page 35: Lecture 5 Curve fitting by iterative approaches MARINE QB III MARINE QB III Modelling Aquatic Rates In Natural Ecosystems BIOL471 © 2001 School of Biological