Top Banner
Statistical advices for biologists Script to a Higher Level Course in Data Analysis and Statistics for Students of Biology and Environmental Protection Werner Ulrich UMK Toruń 2007
123

Statistical advices for biologists

Feb 12, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Statistical advices for biologists

Statistical advices 1

Statistical advices for biologists

Script to a Higher Level Course in

Data Analysis and Statistics for Students of

Biology and Environmental Protection

Werner Ulrich

UMK Toruń 2007

Page 2: Statistical advices for biologists

2 Statistical advices

Contents 1. Introduction..................................................................................................................................................3

2. Planning scientific studies............................................................................................................................4

2.1 Choosing the right statistics .......................................................................................................................7

2.2 How to build a model.................................................................................................................................7

3. Bivariate comparisons..................................................................................................................................9

3.1 Important distributions.............................................................................................................................11

4. Bivariate regression techniques..................................................................................................................16

5. Vecors and Matrices ..................................................................................................................................22

5.1 Vectors .....................................................................................................................................................22

5.2 Matrix algebra..........................................................................................................................................26

6. Multiple regression ...................................................................................................................................43

6.1 How to interpret beta-values ....................................................................................................................47

6.2 Advices for using multiple regression......................................................................................................52

6.3 Path analysis and linear structure models ................................................................................................53

6.4 Logistic and other regression models.......................................................................................................56

6.5 Assessing the goodness of fit ...................................................................................................................58

7. Analysis of variance...................................................................................................................................60

7.1 Advices for using ANOVA......................................................................................................................62

7.2 Comparisons a priori and a posteriori ......................................................................................................74

8. Cluster analysis ..........................................................................................................................................75

8.1 Advices for using cluster analysis............................................................................................................79

8.2 K-means cluster analysis..........................................................................................................................80

8.3 Neighbour joining ....................................................................................................................................81

9. Factor analysis ...........................................................................................................................................83

9.1 Advices for using factor analysis .............................................................................................................88

10. Canonical regression analysis ..................................................................................................................90

10.1 Advices for using canonical regression analysis ....................................................................................91

11. Discriminant analysis...............................................................................................................................92

11.1 Advices for using discriminant analysis.................................................................................................95

12. Multidimensional scaling.........................................................................................................................96

12.1 Advices for using multidimensional scaling ..........................................................................................99

13. Bootstrapping and jackknifing ............................................................................................................... 100

13.1 Reshuffling methods ............................................................................................................................ 103

13.2 Mantel test and Moran’s I .................................................................................................................... 107

14. Markov chains........................................................................................................................................ 109

15. Time series analysis ............................................................................................................................... 116

17. Statistics and the Internet ....................................................................................................................... 121

18. Links to multivariate techniques ............................................................................................................ 122

19. Some mathematical sites ........................................................................................................................ 123

Latest udate: 04.07.2007

Page 3: Statistical advices for biologists

Statistical advices 3

1. Introduction

Our world undergoes a phase of mathematization. Yet 20 years ago in the age before the third industrial,

the PC revolution, it was popular among biology students - at least in our part of the world - to answer the

question why they study biology with the remark that they don't like mathematics. Today such an answer seems

ridiculous. Mathematical and statistical skills become more and more important.

The following text is not a textbook. There is no need to write a textbook again. The internet provides

many very good texts for every statistical method and problem and students should consult these web sites

(which are given at the end of this script) for detailed information on each of the methods described below.

This text is intended as a script to a higher level course in statistics. Its main purpose is to give some practical

advises for using multivariate statistical methods.

I rejected to providing real examples for each method although they would be readily at hand. Instead ,

most methods are explained using data matrices that contain random numbers. I want to show how easy it is to

get seemingly significant results from nothing. Multivariate statistical techniques are on the one hand powerful

tools that might provide us with a manifold of information about dependencies between variables. They are on

the other hand dangerous techniques in the hand of those how are not acquainted to the many sources of errors

connected with them.

The text deals with ten major groups of statistical techniques:

• The analysis of variance compares means of dependent variables under the influence of interact-

ing independent variables.

• Bivariate and multiple regression tries to describe dependent variables from one or more sets

of linear algebraic functions made up of independent variables.

• Cluster analysis groups a set of entities according to the expression of a set of variables defining

these entities.

• Factor analysis is designed to condense a larger set of variables or observations that share some

qualities into a new and smaller set of artificial variables that are easier to handle and to interpret.

• Discriminant analysis is a regression analysis that tries to classify elements of a grouping vari-

ables into predefined groups.

• Canonical regression analysis tries to relate two variable sets, a set of dependent and a set of

independent variables, via a combined principle component and regression analysis.

• Multidimensional scaling arranges a set of variables in a n-dimensional space so that the dis-

tances of these variables to the axes become minimal.

• Resampling techniques, bootstrapping and jackknifing are techniques to infer measures of

reliability from series of samples.

• Markov chains enable us estimating variable states on the basis of transition probabilities.

• Time series and spectral analysis tries to detect regularities (autocorrelation) in series of data.

Page 4: Statistical advices for biologists

4 Statistical advices

2. Planning scientific studies

Any sound statistical analysis needs appropriate data. Any application of statistics to inappropriate or

even wrong data is as unscientific as sampling data without prior theoretical work and hypothesis build-

ing. Nevertheless both types of making ’science’ have quite a long history in biology. One the one hand there is

a strong mainly European tradition of natural history (faunistic, floristic, systematic, morphological) where data

acquisition and simple description dominate. There is an untranslatable German phrase ’Datenhuberei’ for

this. Datenhuberei resulted, for instance, in large collections of morphological, floristic, and faunistic data,

manifested in mountains of insects in alcohol tubes or insect boxes. In many cases, the scientific value of these

data is zero. Another, mainly American tradition is called (also untranslatable) ’Sinnhuberei’, the exaggeration

of theoretical speculations and sophisticated statistical and mathematical analysis. The result was a huge num-

ber of theoretical papers, full of statistics, speculation, and discussion of other papers of the same type, but

without foundation in reality.

Science but has to be founded both in good data and in good theory. The first thing however must be

theory. Because this is still not always clear to students and even scientists I shall give a short introduction to

the planning of scientific work. The scheme beside shows a very general model of how to plan a scientific

study. It is based on a more specific scheme of Jürgen Bortz (Statistik für Sozialwissenschaftler, Springer 1999)

designed for the social sciences. We can identify six main phases of a scientific study. The first phase must

always be a detailed analysis of the existing literature, where the problem to be solved is clearly stated. Based

on this the second theory building phase consists in the formulation or adaptation of a sound and logical the-

ory. A theory is a set of axioms and hypothesis that are formalized in a technical language. What we need is a

test whether our theory is logically sound. We also need models for testing it and criteria for accepting or modi-

fying it. Hence, we must formulate specific hypotheses that follow from our theory. These hypotheses have to

be tested by experiments or observations. And we must formulate exactly when to reject our hypotheses.

Next come the planning and data acquisition phases. Planning has to be done with the way of data analy-

sis in mind. Often pilot studies are necessary. Data sizes have to be estimated by power analysis. The analyti-

cal phase consists of setting appropriate significance levels for rejecting the hypothesis and of choosing appro-

priate test statistics. In this phase many errors occur when choosing tests for which the data set is inappropriate.

The data have to be checked whether they met the prerequisites of each test. Therefore, be aware of the possi-

bilities and limitations of the statistical tests you envision prior to data analysis.

The last phase is the decision phase. The researcher has to interpret the results and to decide, whether the

hypotheses have passed the tests and the theory seems worth further testing or whether all or some hypotheses

must be rejected. In the latter case the theory requires revision or must also be rejected.

Page 5: Statistical advices for biologists

Statistical advices 5

Definition of the problem, study of literature

Formulating a general theory

Logical verificationnegative

positive

Deducing hypotheses

Formulating criteria for accepting hypotheses

Planning of the study; Experimental design

Deducing appropriate null models

Getting data

Data appropriate

no

Setting significance values α for acceptance

Choosing the appropriate statistical test

P < α Study ill designed

Theory exhausted

Modifying theory

Criterion for accepting hypotheses fulfilled

Theory useful

Formulating further tests of the theory

Searching phase

Theoretical phase

Planning phase

Observational phase

Analytical phase

Decision phase

yes yes

no no

yes

yes

no

yes

no

Theoryinappropriate

Page 6: Statistical advices for biologists

6 Statistical advices

Page 7: Statistical advices for biologists

Statistical advices 7

2.2 How to build a model Why is it necessary to build mathematical models using experimental or observational data? There are several

reasons for this. Biology has transformed from natural history (history!) to an explanatory science. It not

only tries to describe phenomena in nature it tries to understand causes and relations. For this task we have to

structure our observations and to look for relations between them. This is exactly the modelling process: we

use the science of structures, mathematics, to uncover hidden patterns and relations. Modelling is there-

fore more than finding out whether sample means differ or whether we have simple correlations between data.

We have to parametrize these relations. But models have many other tasks. First of all, they generate new pre-

dictions about nature, predictions that then have to be verified or falsified. This prediction generating feature is

of course also a method to verify our model. Secondly, good models allow predictions to be make about the

future. This is a main aim for all environmental models. They are designed to predict the future of populations,

ecosystems and biodiversity. At last models reduce the chaos in our data and allow by this the development of

new theories and concepts.

Models can be classified into certain classes. On one end of a continuum we have verbal models stating more

or less precisely relations between a set of variables. These verbal statements may be incorporated into dia-

grams where the variables are connected by arrows. Then, we have a qualitative model. On the other end,

there are explicit mathematical models that formalize relations. These relations may be fully parametrized and

then we have a quantitative model that gives quantitative predictions about variable states. At least, models

may contain exact parameter values at all stages of computation. We speak of deterministic models because

2.1 Choosing the right statistics Choosing the right statistic, the statistical test for which our data set is appropriate, is not easy. The first

step in planning a study should involve an idea of what we later want to do which the data we get. We should

already envision certain statistical methods. We have to undertake a power analysis to be sure that we get

enough data for our envisioned test.

The scheme beside shows a short, and surely incomplete, map of how to choose a statistical test on the

basis of our data structure. A first decision is always whether we want to deal with one, with two or with

several variables simultaneously. We have also to decide whether we want to test predefined hypotheses or

whether we want to apply methods that just generate new hypotheses. We must never mix up hypothesis gen-

erating and hypothesis testing with the same data set and the same method.

If we have larger data sets we might divide these data into two (or even more groups) and apply our sta-

tistics to one set for hypothesis generating and to the second set for testing. But we must be sure that both sub-

sets are really independent and might form different and independent samples from the population.

Beside the question about the number of variables the scheme leads us to two other important questions.

First, what is the metrics of our data, metric, non-metric or mixed? Second, are our data in accordance

with the general linear model (GLM) or not? This leads us to the decision whether to apply a parametric

or a non-parametric test.

Page 8: Statistical advices for biologists

8 Statistical advices

all future states of the models can in principle be computed by the initial set of values. On the other hand, the

model might contain more or less stochastic variables, variables that are driven by random events. In this case,

future parameter values are less sure or even chaotic. In this case we speak of stochastic models.

This short discussion indicates already what we need to build a model.

• The first step is that we have a theory. Shortly speaking, a theory is a set of hypotheses stated in

a formal language. We need hypotheses about nature and the relations between certain variables.

Modelling without a priori theoretical reasoning will lead to nothing. Our a priori experience

must lead to a selection of variables, so-called drivers, of the model. These drivers might have

explicit or stochastic values. They might be parametrized (characterized by explicit values or

functions) or not. In the latter case the model itself should assign values or value ranges to these

parameters.

• Then, we have to collect the necessary data. These data have to match the requirements of our

theory. Making experiments or observations without an explicit theory in mind will very often

result in large sets of data without any value because afterwards we (suddenly) notice that one or

another important variable had been ignored and not measured or that our method was inappro-

priate to incorporate the variable values of the model. This latter case occurs very often if we

took to less replicates and the variances are too high. Problems also arise if we used different

methods for observations and we later notice that these differences make it impossible to com-

pare the data (for instance because they differ in the degree of quantitativeness).

• In a next step we have to confirm assumed relations between these drivers. We might assign

qualitative or quantitative relations. If we quantify the relations (for instance from a regression

analysis) we parametrize these relations.

• Then, we have to formalize the relations. This is best done by a flow diagram or flow chart.

The flow diagram forces us to write each relation and each step of the model explicitly. This step

often uncovers smaller or larger errors in our initial model that would have remained undiscov-

ered in a purely verbal model formulation. Making flow diagrams learns us thinking hard!

• The following step is then a technical one. Rewriting our flow diagram into a computer algo-

rithm. For more complex models this should be a done using a common computer language like

C++, R, Matlab, Visual Basic, or Fortran, simple models can be written via a spreadsheet pro-

gram like Excel.

• Our model will generate a set of output variables or whole classes of relations. We have to check

these parameters, whether their values are realistic, whether they correctly predict real values and

whether they are able to predict the future.

• At the end we have to modify our model in the light of its predictions and variable states.

Page 9: Statistical advices for biologists

Statistical advices 9

3. Bivariate comparisons

For simple comparisons of means we use the t-test based on the t-distribution. The non-parametric alter-

native is the U-test. This test should be preferred at small sample sizes, skewed or multimodal distributions of

errors and if we have outliners. However, many tied ranks also distort error levels of the U-test (Figs. 3.1, 3.2).

In this case permutation tests should be preferred. This is shown in the next Past example. We have two sam-

ples and want to compare the means. The t-test rejects the hypothesis of a significant difference at p > 0.05.

The U-test gives a similar result. However, we have a small sample size and tied ranks. A permutation test that

reshuffles all values across both samples points to a significant difference.

Errors are not normally distributedaround the mean

Comparingtwo means

Comparingexpectation

and observation

Analyzing dependenciesbetween two variables

Sign testMonte Carlo simulation

U-testWilcoxon test

Sign test

Rank correlation

Comparingtwo means

Studying structure

Monte Carlo simulation

What kind of test to be used?

Errors are normally distributedaround the mean

Errors are not normally distributedaround the mean

Comparingtwo means

t-test

Comparingtwo variances

F-test

effect sizeoverall standard error

t =

1 2

2 21 2

x xt N

σ σ

−=

+

2122

F σσ

=

Comparingtwo distributions

Comparingexpectation

and observation

Chi2-test

22

1

( )ki i

i i

Obs ExpExp

χ=

−= ∑

22

1

( )ki i

i i

Obs ExpExp

χ=

−= ∑

Chi2-test

Kolmogorov -Smirnov-test

max( )cum cumKS Obs Exp= −

Chi2-test

G-test

12 ln

k

i

OG OE=

⎛ ⎞= ⎜ ⎟⎝ ⎠

∑Fig. 3.1

Fig. 3.2

Page 10: Statistical advices for biologists

10 Statistical advices

Two distributions are compared with a χ2 test. A

special important usage of the χ2 test is its application

for comparing the outcomes in a twofold grouped vari-

able. Assume we undertake a genetic study. We test

1000 fruit flies. We find 110 times that an allele A that

occurred 200 times was combined with the occurrence

of curled hairs. In turn, curled hairs were 600 times

associated with allele B. Does allele A influence the

frequency of curled hairs? We have only data from one

population and single data points. We have no measure of variance. A t-test can’t be applied. Nevertheless we

are able to test our hypothesis that the frequencies changed. We make the following table (Fig. 3.3), a 2x2 con-

tingency table. It is the basis for a special case of the χ2 test, the 2x2 contingency χ2 test. We compute squares

of differences, that means variances. These are χ2 distributed.

With the table we can compute expected probabilities. The total fre-

quency of curled hairs in the population is 585/1000. Allele A has a

total frequency of 0.2. Hence we expect 0.2*585 ≡ 117 flies with allele

A and curled hairs. We the same logic we get 0.8*585 ≡ 468 flies with

curled hairs and allele B. The two other fly numbers come from A and

normal hairs = 200-117 = 83 and B and normal hairs = 800-468 = 332.

Now we have all to apply an ordinary χ2 test. We have 4 data points

with associated expectancies. Because we computed the expected fre-

quencies from four data points the number of degrees of freedom is

only one. df = 1. We compute by hand

Excel gives =ROZKŁAD.CHI(1.26,1) = 0.2614. This value (and the χ2 test value) are identical to the one of

Statistica (p = 0.2614). Our interpretation is that A and B lead to the same frequencies of curled hairs. Below

is shown how to compute the test using Excel.

2 2 2 22 (110 0.2*585) (475 0.8*585) (90 83) (325 332) 1.26

0.2*585 0.8*585 83 332χ − − − −

= + + + =

110 475

90 325

Curled

Normal

A B

200 800

585

415

1000

Fig. 3.3

Observed Chi2

A B Sum A B 1 10 20 30 1 0.061 0.067

2 3 0 3 2 5.452 =(D4/D10)^2/D10

Sum 13 20 Grand sum 33 5.580

Expec-ted p

A B Sum 0.018

1 11.818 18.182 30 =ROZKŁAD.CHI(G$6;1)

2 1.182 =$E4*D$5/$E$6 3

Sum 13 20

Page 11: Statistical advices for biologists

Statistical advices 11

3.1 Important distributions

Elementary statistical tests are based on certain statistical distributions. These can often be approximated

by the normal distribution. In the first statistic course we dealt with certain discrete distributions (Bernoulli,

hypergeometric, Pascal, Poisson) and with the continuous normal (and lognormal) distribution.

Now we deal with other important continu-

ous distributions In Fig. 3.1 the factorials are

marked with black quadrates. We see that for x = 1

the function value becomes 1 for x = 2 also 1, for x

= 3 y = 2!, for x = 4 y = 3!, for x = 5 y = 4! and so

on. The factorial is a discrete function. What is if

we would try to define 3.5!? We would have to

generalize the factorial. This generalization is done

by the Gamma function introduced by the great

Swiss mathematician Leonhard Euler (1707-1783, his Introductio in analysin infinitorum founded the analysis

as an independent part of mathematics).

For all positive real numbers x is Γ(x) defined as

(3.1.1)

Hence Γ(3.5) = 2.5*Γ(2.5) = 2.5*1.5*Γ(1.5)=2.5*1.5*0.5*Γ(0.5).

For natural x holds therefore

Γ(x +1) = x!

Γ(1) = Γ(2) = 1

But we have no possibility to compute Γ

(1.5). Euler found a solution and defined Γ(x) by

the Euler integral

(3.1.2)

From this we get

(3.1.3)

The latter function is our already known Euler dis-

tribution.

Additionally holds

Γ(x)*Γ(1-x) = π / sin(πx)

( 1) ( )x x xΓ + = Γ

-t 1

0

(x)= e ; (x>0)xt dt∞

−Γ ∫

0

0

(1) 1

and

(2) 1

t

t

e dt

te dt

∞−

∞−

Γ = =

Γ = =

0

0.05

0.1

0.15

0.2

0.25

0.3

0 2 4 6 8 10x

f(x)

f(x,3)

0

5

10

15

20

25

30

0 1 2 3 4 5 6x

Γ(x)

Fig. 3.1.1

Fig. 3.1.2

Page 12: Statistical advices for biologists

12 Statistical advices

and therefore for z = 0.5

Γ(1/2) = π1/2

The gamma function defines an important distribution, the gamma distribution defined by

(3.1.4)

With this function it is easy to compute the gamma function. Excel computes f(x,α). Hence to compute

Γ(α) you transform

Γ(α) = exp(-x)x(α-1) / f(x,α).

Fig. 3.1.2 shows an example of the gamma distribution f(x,3). The Fig also shows one reason for the

importance of this distribution. It is frequently applied to model skewed natural distributions because the model

parameter α can be appropriately adjusted.

Another reason for the importance is the fact that via the gamma function discrete probability distribu-

tions that contain factorials can be transformed into continuous ones.

For instance the negative binomial is often written in the form

One special case of the gamma distribution

is the χ2-distribution. Assume we have n inde-

pendent random variates. All are Z-transformed

and have the mean zero and the variance one. Ac-

cording to the central limit theorem the sum of

these variates should be asymptotically normally

distributed with a mean of zero (the sum of all

means) and a variance of n. In effect we add up

means. What is if we add up variances? Simplified we compute

(3.1.5)

This is the χ2-distribution introduced by the German mathematician R. F. Helmert (1841-1917). Its den-

sity function is

(3.1.6)

As the gamma distribution the χ2-distribution is not a single distribution. It denotes a whole class of dis-

tributions depending on the number of random variables n. n is called the degree of freedom of the distribu-

tion.

χ2 distributions are additive that means

1

( , )( )

xe xf xα

αα

− −

( 1)( , ) (1 )( ) ( 1)

k xx kf x k p px k

Γ + −= −

Γ Γ −

2 2

1=

= ∑n

ii

/ 2 ( 2) / 2/ 2

1( )2 ( / 2)

x nnf x e x

n− −=

Γ

2 2 2n 1 n 1χ χ χ −= +

Page 13: Statistical advices for biologists

Statistical advices 13

For large n χ2 approaches again a normal distribution. If we add up the variances (all having the value

one) the mean, the variance, and the skewness of the new χ2 random variate has

(3.1.7)

For large n we can transform a χ2-distribution into a standard normal distribution by applying the Z-

transformation

(3.1.8)

The next important distribution we have to deal with is the student or t-distribution introduced 1908 by

the British mathematician William Gosset (1876-1937) under the pseudonym ’student’. Assume a normal dis-

tributed random variate Z with μ = 0 and σ2 = 1. Additionally we have a χ2-distribution with n degrees of free-

dom. Gosset now defined a t value of

(3.1.9)

The density function of the t-distribution is very complicated and not interesting for us. Interesting in-

stead is that the t-distribution has a mean and a variance of

with n being again the number of degrees of freedom. Unfortunately Excel only computes cumulative χ

2- and t-distributions. However every statistic package has a probability calculator and gives the appropriate

density function values.

If we have two χ2-distributions with n1 and n2 degrees of freedom we define

(3.1.10)

as the F-distribution (introduced by the British biostatistician Sir Ronald Fisher (1890-1962). For large n this

distribution again approximates a normal distribution. t-, χ2-, and F- distributions are closely connected.

(3.1.11)

The last important distribution we deal with is the Weibull distribution (after the Swedish mathemati-

cian Waloddi Weibull, 1887-1979)

2 2

8

nn

n

μ

σ

γ

=

=

=

2

2n nz

nχ −

=

2 /n

n

ztnχ

2

0

2n

n

μ

σ

=

=−

22 1

n1,n2 21 2

nFn

χχ

=

222 1n 1,n2 2

n n

zt n n Fχχ χ

= = =

Page 14: Statistical advices for biologists

14 Statistical advices

(3.1.12)

We get the cumulative density distribution from

the integral

(3.1.13)

For β = 1 the Weibull distributions equals al simple

exponential function. For β = 3 the distributions

approximates (but not equals) a normal, for larger

b the distribution becomes more and more left

skewed.

The Weibull distribution is particularly used in the

analysis of life expectancies and mortality rates.

We simply model the mortality rate m using a gen-

eral power function model

Using S(t) as the distribution of survival and modelling this via an exponential model under the assump-

tion that the mortality rate is constant we get

For this usage the Weibull distribution is rewritten in a two parametric from

(3.1.14)

where T denotes the characteristic life expectancy and t the age. f(β) gives then the probability that a given

person will die at age t. T is the age at which 63.2 % of the population already died. We get T from eq. 3.1.13

with α = 1 by setting t = T.

Having now data on age specific mortality rates f(β) we can estimate the characteristic life expectancy T

and the shape parameter β. The parameterized model then allows for calculation survival and mortality rates

and associated demographic variables at any given

time t (Fig. 3.1.4). The Fig. shows the cumulative

mortality rates in dependence of time for T = 100

and different β using eq. 3.1.13.

Having data on mortality rates we can estimate

the characteristic life time T from eq. 3.1.13. We

use a double log transformation

1 xf ( , ) x eββ− −αα β = αβ

xF( , ) 1 eβ−αα β = −

10m(t) m tβ−=

0m tS( t ) eβ−=

t1Ttf ( ) e

T T

β⎛ ⎞β − −⎜ ⎟⎝ ⎠β

β =

tx T 1F(1, ) 1 e 1 e 1 0.632

e

β

β −−β = − = − = − =

0

0.2

0.4

0.6

0.8

1

1.2

1.4

0 1 2X

f(x)

β = 0.5

β = 1β = 2

β = 3

Fig. 3.1.3

0

0.2

0.4

0.6

0.8

1

0 50 100 150t

F

b=1b=2b=3b=4

T = 100

Fig. 3.1.4

Page 15: Statistical advices for biologists

Statistical advices 15

(5.20)

Using the cumulative mortality rates of the first tables we

obtain b from the slope of a plot of ln[ln(1-F)] against ln

(t) (Fig. 5.3) We get a slope of 1.20, typical for many in-

sects that have an exponential mortality - time distribu-

tion. The intercept b is

This is the characteristic life expectancy. Interpolating the

first second column of the initial table give for 630 individuals to have died a very similar result around two

years.

tln[ ln(1 F( )] ln ln(t) ln(T)T

β β β β⎛ ⎞− − = = −⎜ ⎟⎝ ⎠

0,891,2b (lnT) T e 2.09

−−

= − → = =β

y = 1.2009x - 0.8888

-1.5

-1

-0.5

0

0.5

1

1.5

2

2.5

0 0.5 1 1.5 2 2.5

ln(t)

ln[-l

n(1-

F)]

Fig. 3.1.4

Page 16: Statistical advices for biologists

16 Statistical advices

4. Bivariate regression

If we have two variables we often want to infer

whether both variables are related. If these variables

are metrically scaled we can apply a regression. In the

case of ordinary or nominal scales some association

index might be applied. Association indices are dealt

with below. A regression is most simply done using

Excel or other spreadsheet or statistics programs. You

have a x and a y variable and plot x versus y. Excel

automatically gives the associated linear or non-linear (power, logarithmic, exponential, or algebraic) function

and the coefficient of determination R2. To calculate the regression equation Excel and other programs use or-

dinary least squares regression (Fig. 4.1). The sum of all squared distances Δy is minimized:

(4.1)

Hence we have to solve

(4.2)

and get

(4.3)

with sxy being the covariance of x an y.

(4.4)

The coefficient of correlation is then defined as

(4.5)

This is well known and needs no further explanation. However, a this stage most errors start. First we

have to make clear what we really did. Did we have any well founded hypothesis about the relationships be-

tween X and Y. There are several possibilities:

• A change in x causes respective changes in y. Under this hypothesis x is the independent and y

the dependent variable.

2 2

1 1( ) [ ( )]

= =

= Δ = − +∑ ∑n n

i ii i

D y y ax b

1

1

2 ( ) 0

2 ( ) 0

δδδδ

=

=

= − − − =

= − − − =

n

i i iin

i ii

D x y ax baD y ax bb

2

σσ

= xy

x

a

n

i ii 1

xy

(x x)(y y)S

n=

− −=

σσ σ

= xy

x y

r

0

5

10

15

20

25

30

0 5 10 15 20 25 30

x

y

ΔyΔy

Δy

Δy

Fig. 4.1

Page 17: Statistical advices for biologists

Statistical advices 17

• A change in y causes respective changes

in x and we have to invert our relation-

ship

• x and y are mutually related

• x and y are not directly related and the

observed pattern is caused by a third or

more hidden factors that influence both,

x and y. In this case there is no causal

relationship between x and y. We speak

of a pseudo-correlation

• x and y are neither directly nor indirectly

related. The observed pattern is pro-

duced accidentally.

Hence, we have to decide whether x is really

independent and whether y is really dependent on x.

Further we first have to establish whether the prerequi-

sites of linear least squares regression are met. Often

this relationship is not so clear as it seems. Look at

Figures 4.2 to 4.4. In the first case I plotted numbers

of predator species against numbers of prey species.

With some justification we can assume that predators

dependent on prey although it is known from ecologi-

cal modelling that there are mutualistic relationships

and prey can also be seen as being dependent on

predators. Anyway the relationship appears to be lin-

ear and we can apply ordinary least squares.

This is not the case in Fig. 4.3. Of course brain weight depends on body weight but this relationship is

best described by a power function. Hence we have a non-linear relationship. Now we have two possibilities.

We might linearize the power function

(4.6)

with ε being the error to be minimized by the regression.

Hence our model to fit contains the error term ε in a multiplicative form. In other words, we assume that

errors are lognormally distributed around the means and stem from multiplicative processes. This has to be

established before applying this type of regression.

As an alternative we might apply non-linear regression. Most statistics packages contain non-linear re-

z

z

W aB ln W ln a z ln B

ln W ln a z ln B

W aB Exp( )

ε

ε

= → = +

↓= + +

=

y = 9.24x0.73

R2 = 0.950.1

110

100

100010000

100000

0.001 1 1000Body weight [kg]

Bra

in w

eigh

t [g]

Mammals

y = 4.4x0.53

R2 = 0.191

10

100

1000

1 10 100Poplar plantation

Agr

icul

tura

l fie

ld Ground beetles at two adjacent sites

y = 1.16x + 4.17R2 = 0.49

0

20

40

60

80

100

0 10 20 30 40 50# prey species

# pr

edat

or s

peci

es

Fig. 4.2

Fig. 4.3

Fig. 4.4

Page 18: Statistical advices for biologists

18 Statistical advices

gression modules. They also use least squares but compute them directly from our non-linear function we in-

tend to fit. In this case we apply the following model

(4.7)

Now we treat the errors as being normally distributed around the mean and result from additive error

generating processes. Both models make different assumptions about the underlying processes and predict dif-

ferent regression functions. In Figs. 4.5 and 4.6 I computed exponential and power function distributed values

using one time an additive and one time a multiplicative error term. In Fig. 4.5 I used Y=e0.1X +norm(0,Y),

where norm was a normally distributed random variate. A fit by the nonlinear estimation module of Statistica

(the red trend line) gave a result quite close to the model parameters. The Excel build in fitting function, in

turn, predicted a too high intercept and a too low slope. This function uses log-transformation (ln Y = aX +ε)

and assumes therefore a different distribution of errors. The log transformation reduces the absolute differ-

ences between the Y values. Hence the largest Y values have less influence on the regression. The log trans-

formation gives more weight to smaller values. In Fig. 4.6 I used a multiplicative error (Y = X0.5enorm(0,Y). The

non-linear estimation predicts a too low slope and a too high intercept. However, the Excel fit, although using

log-transformed values and therefore the correct error distribution, predict a too high slope and a too low inter-

cept. In general the nonlinear estimation appears to be closer to the generating parameter values. Further we see

that in this latter case the larger X values have a higher influence on the non-linear fit and force the regression

line to a lower slope.

Next look at Fig. 4.4. In this case we compared a plantation and a field. There are no clear dependent

and independent variables. Further, both variables have error terms, whereas ordinary lest squares regression

(OLR) assumes only the dependent variable of have errors. Hence important prerequisites of OLR are not met.

If the errors in measuring x would be large our

least square regression might give a quite mis-

leading result. This problem has long been

known and one method to overcome this prob-

lem is surely to use Spearman’s rank order cor-

relation. However we may also use a different

method for minimizing the deviations of data

points from the assumed regression line. Look

z

z

W aB

W aB ε

=

= +

y = 0.60x0.56

0.1

1

10

100

1 10 100 1000 10000x

y

y = 1.57x0.46y = 1.16e0.089x

0

20

40

60

80

100

0 20 40x

yy = 1.04e0.098x

Fig. 4.5 Fig. 4.6

0

5

10

15

20

25

30

0 5 10 15 20 25 30

x

y

Δy

Δx

Δy

Δx

OLRy

OLRxΔx

Δy

RMAMAR

Fig. 4.7

Page 19: Statistical advices for biologists

Statistical advices 19

at Fig. 4.7. Ordinary least square regression de-

pends on the variability of y but assumes x to be

without error (OLRy). But why not using OLR

based on the variability of x only (OLRx)? The

slope a of OLRx is (why?)

(4.8)

Now suppose we compute OLEy and OLEx sepa-

rately. Both slopes differ. One depends solely on

the errors of y, the other solely on the errors of x.

We are tempted to use the mean value of both

slopes as a better approximation of the ’real’

slope. We use the geometric mean of both slopes

and get.

(4.9)

In effect this regression reduces the diagonal dis-

tances of the rectangle made up by Δy and Δx as

shown in Fig. 4.7. Due to the use of the geometric

mean it is called the geometric mean regression

or the reduced major axis regression (also stan-

dard major axis regression). Due to the use of

standard deviations the method uses standardized

data instead of raw data. Eq. 4.9 can be written in a slightly different form. We get (why?)

(4.10)

The RMA regression slope is therefore always larger than the ordinary least square regression slope

aOLRy. Hence, if an ordinary least square regression is significant the RMA regression is significant too.

Lastly, the most natural way of distance and minimizing distances to reach in a regression slope is to use

the Euclidean distance (Fig. 4.9). If we use this concept we again consider the errors of x and those of y. This

technique is called major axis regression (MAR). However, in this case the mathematical background be-

comes already quite complicated. The MAR slope becomes

(4.11)

with λ being

2y

OLRxxy

sa

s=

2

2' x y y yR M A

x x y x

s s sa a a

s s s= = =

y OLRyRMA

x

s aa

s r= =

2xy

MARy

sa

sλ=

Fig. 4.8

Fig. 4.9

Page 20: Statistical advices for biologists

20 Statistical advices

(4.12)

OLRx and OLRy are termed the model I regression. RMA and MAR are also termed model II regres-

sion.

Of course , the intercept of all these regression techniques is further computed from the means of X and

Y

(4.13)

Figure 4.10 shows a comparison of all four regression techniques. We see that at a high correlation coef-

ficient of 0.77 the differences in slope values between all four techniques are quite small. Larger differences

2 2 2 2 2 2 2 2( ) 4( )2

x y x y x y xys s s s s s sλ

+ + + − −=

b y ax= −

05

10152025303540

0 5 10 15 20 25 30x

y

OLRy

OLRx

RMAMARx

05

10152025303540

0 5 10 15 20 25 30x

y

OLRy

OLRx

RMAMARx

05

101520253035404550

0 5 10 15 20 25 30x

y OLRy

OLRx

RMAMARx

0

50

100

150

200

250

300

0 5 10 15 20 25 30x

y

OLRy

OLRx

RMA

MARx

05

10152025303540

0 5 10 15 20 25 30x

y

OLRy

OLRx

RMAMARx

05

10152025303540

0 5 10 15 20 25 30x

y

OLRy

OLRx

RMAMARx

020406080

100120140160180

0 10 20 30 40 50x

y

OLRy

OLRx

RMAMARx

0

10

20

30

40

50

60

70

0 10 20 30 40x

y

OLRy

OLRx

RMA

MARx

Fig. 4.10

Fig. 4.11

Page 21: Statistical advices for biologists

Statistical advices 21

but would occur at lower correlation

coefficients. The Excel model

shows also how to compute a model

II regression. They are not imple-

mented into Excel and major statis-

tic packages although they are re-

cently very popular among biolo-

gists. The program PAST is recently

the only common package that com-

putes default RMA slopes (Fig. 4.9).

Figs. 4.10 and 4.11 show how the

four regression models behave if we

introduce outliners. We see that

OLRx and MAR react strong on a single outliner whereas RAM and OLRy behave more moderate. RMA ap-

pears to be least affected by the outliner while in all cases giving reasonable regression lines.

This leads us to the question of model choice (Fig. 4.12). When to use which type of regression? In gen-

eral model II regression should be used when we have no clear hypothesis what is the dependent and what the

independent variable. The reason is clear. If we don’t know what is x and y we also can’t decide which errors

to leave out. Hence we have to consider both errors, those of x and those of y. If we clearly suspect one vari-

able to be independent we also should use model II regression if this variable has large measurement errors. As

rule of thumb for model I regression the errors of x should be smaller than about 20% of the errors in y. Hence

sy < 0.2sx. Lastly, if the we intend to use a model II regression, we should use MAR if our data are of the same

dimension (of the same type, for instance weight and weight, mol and mol, length and length and so on). Other-

wise a RMA regression is indicated.

However, all these advices have only importance if we deal with loosely correlated data. For variables

having a correlation coefficient above 0.9 the differences in slope become quite small and we can safely use an

ordinary least square regression OLRy. Additionally, there is an ongoing discussion about the interpretation of

RMA. RMA deals only with variances. The slope term does not contain any interaction of the variables (it

lacks the covariance). Hence, how can RMA describe a regression of y on x? Nevertheless especially RMA and

MAR have become very popular when dealing with variables for which common trends have to be estimated.

Linear regression

Model I Model II

Errors of independent variable smaller

Independent variable has larger

measurement errors

OLEy OLEx

x→y y→ x

MAR RMA

Varia-bles ofsame dimen-sion

Varia-bles of

differentdimen-

sion

Clear hypotheses about dependent and independent variables

Variables cannot be divided intodependent and independent ones

Fig. 4.12

Page 22: Statistical advices for biologists

22 Statistical advices

5. Vectors and Matrices

5.1 Vectors

Given a point in space we can shift this

point to another place. The arrow that goes from

the original point to its new place is called a vec-

tor. In Fig. 5.1.1 we have three vectors A, and B,

and a vector C that point back to itself. This is

called a null vector. In a Cartesian system vectors

are given by the coordinates of the endpoint minus

the coordinates of the starting point. Hence in Fig.

5.1.1

Hence all vectors with identical x and y

values are identical. Further

The vector B is parallel to A but points in

the opposite direction. That mean B = -A. In Fig.

5.1.2 the vectors I and j are given by

The vector A can be seen as the multiplication of a

number a1 with i and a2 with j. In vector algebra numbers are called scalars. Hence

E call the scalars a1 and a2 the coordinates of the vectors A. The null vector is therefore defined by o =

{0,0} and the unity vectors are I = {1,0) and J = {0,1}.

We can define vectors I more than two dimensions. The general form of a vector in an n-dimensional

space is

The examples above provide a natural introduction to basic vector operations. The addition and subtrac-

tion of vectors are defined as

20 5 15A

20 10 10−⎛ ⎞ ⎛ ⎞

= =⎜ ⎟ ⎜ ⎟−⎝ ⎠ ⎝ ⎠

5 20 15 15B 1 A

2 12 10 10− −⎛ ⎞ ⎛ ⎞ ⎛ ⎞

= = = − = −⎜ ⎟ ⎜ ⎟ ⎜ ⎟− −⎝ ⎠ ⎝ ⎠ ⎝ ⎠

1 0i ; j

0 1⎛ ⎞ ⎛ ⎞

= =⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

1

2

a iA

a j⎛ ⎞

= ⎜ ⎟⎝ ⎠

1

n

a...

V...a

⎛ ⎞⎜ ⎟⎜ ⎟=⎜ ⎟⎜ ⎟⎝ ⎠

0

5

10

15

20

25

0 5 10 15 20 25x

y

A

B

C

Fig.5.1.1

0

1

2

3

4

5

6

0 1 2 3 4 5 6x

y

A

a1i

a2j

ij

Fig.5.1.2

Page 23: Statistical advices for biologists

Statistical advices 23

(5.1.1)

In two-dimensional space this can be inter-

preted as generating a parallelogram from the vec-

tors A and B that has the longer diagonal of C (Fig.

5.1.3). Consequently a subtraction A - B is defined

as an addition of the antivector of -B and A (Fig.

5.1.4).

(5.1.2)

Both definitions of course hold for additional di-

mensions too.

Basic theorems for addition and subtractions

hold for vectors too. Both operations are commuta-

tive, and associative. Hence

(5.1.3)

An addition of A with the null vectors gives

A and A - A gives the null vector o.

Next we define the multiplication. There are

three types of vector multiplication. The first is the

multiplication with a scalar, the scalar multiplica-

tion (or S-product). Fig. 5.1.5 shows a natural

definition of the S-product. We get

(5.1.4)

The S-multiplication if commutative and distributive (Fig. 5.1.5).

(5.1.5)

1 1 1 1

2 2 2 2

a b a ba b a b

+⎛ ⎞ ⎛ ⎞ ⎛ ⎞+ =⎜ ⎟ ⎜ ⎟ ⎜ ⎟+⎝ ⎠ ⎝ ⎠ ⎝ ⎠

1 1 1 1 1 1

2 2 2 2 2 2

a b a b a ba b a b a b

− −⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞− = + =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟− −⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

A B B AA (B C) (A B) CA o AA A o

+ = ++ + = + ++ =− =

1 1 1 1

n n n n

a a a aA ... ... ... ... ...

a a a a

λλ λ

λ

⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟= = + + =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

( A ) ( )A(A B ) B A

( )A A AoA o

=+ = +

+ = +=

γ λ γλλ λ λλ γ λ γ

0

1

2

3

4

5

6

0 1 2 3 4 5 6x

y

C

a1

A

B

a2 b1

b2

a1+ b1

a2+ b2

Fig. 5.1.3

0

1

2

3

4

5

6

0 1 2 3 4 5 6x

y C

a1

A-B

a2

-b2

-b1a1- b1

a2- b2

A

B

a2

a1

b2

b1

Fig. 5.1.4

0

1

2

3

4

5

6

0 1 2 3 4 5 6x

y

A A A

B

B

BA+B

A+B

A+B 3b

3a

Fig. 5.1.5

Page 24: Statistical advices for biologists

24 Statistical advices

The length of a vector is of course given by the law of Pythagoras

(5.1.6)

This definition implies that the length of |A + B| ≤ |A| + |B|.

We can multiply two vectors to get a scalar. This is called the scalar product and is defined as

(5.1.7)

The commutative, distributive and the mixed associative laws hold

(5.1.7)

The simple associative law does not hold A•(B•C) ≠ (A•B)•C because ne time we get a vector in

direction A and the other a vector in direction C.

Improtant is the case when we multiply two vectors

that are perpendicular. Two dimensional

perpendicular vectors have the folowing structure

(Fig. 5.1.6)

(5.1.8)

Hence if the scalar product of two non-sero vectors

is zero they are perpendicular. Important is also

that the equation A•X=b has an indefinite number

of solutions. Further the division through a vecto

is not defined.

The scalar product has a simple geometrical

interpretation. It is the product of the length of A

with the perpendicular projection c1 of B on A

(Fig. 5.1.7)(why?). Because of c1/ |B| = cos(α) we

get

(5.1.9)

If α = π/2 A•B = 0. Further we get A•A=|A|2.

The use of vectors allow for some easy proofs of

geometrical theorems.

For instance the cosine theorem can be derived

2 21 nA a ... a= + +

1 1 n

1 1 2 2 i ii 1

n n

a b... ... a b ... a b a ba b =

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟• = + + =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

A B B AA (B C) (A B) A C

(A B) ( A) B A ( B)A o oλ λ λ

• = •• + = • + •

• = • = •• =

x yA ;B A B xy xy 0

y xλ

λ λλ

⎛ ⎞ ⎛ ⎞= = → • = − =⎜ ⎟ ⎜ ⎟−⎝ ⎠ ⎝ ⎠

A B A B cos( )α• = •

0

2

4

6

8

10

0 2 4 6 8 10x

y

. AB

{-1,2} {4,2}

Fig. 5.1.6

0

2

4

6

8

10

0 2 4 6 8 10x

y

. AB

{a1,a2}

{b1,b2}

α

c2

c1

Fig. 5.1.7

Page 25: Statistical advices for biologists

Statistical advices 25

using a triangle made of three vectors C=A-B. and A•B = |B| |B| cos(γ). Hence

For γ = π/2 we get the theorem of Pythagoras.

Important fields to use vectors are trigonometry and ana-

lytical geometry. Using vectors of unit length we can de-

fine an angle α from

Further we can define projections of geometrical objects.

For instance a parallel shift of a length A by a vector V

(Fig. 5.1.9) is given by

Using vectors we can define straight lines in space (Fig.

5.1.10). The line A to point P is given by

(5.1.10)

This equation makes is easy to calculate geometrical rela-

tionships. For instance do the straight lines defined by the

points A1 = {1,2,3} and A2 = (4,5,6} and B1 = {2,3,4}

and B2 = { 5,4,3}cross? We compute

and see that γ =0 and λ = 1/3 fulfil this equation. Both

straight lines cross in the point P = {2,3,4}.

If we have two point A and B on a straight line and the

direction vector U the straight line is defined by the vec-

tor P from A to B by

2 2 2 2 2 2 2 2C c (A B) A 2AB B c a b 2abcos( )λ= = − = − + = = + −

1 2 1 2E E E E cos( ) cos( )α α• = =

1 1 1 11 2

2 2 2 2

a v a v1 0A A' a a

a 0 1 v a v+⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞

= → = + + =⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ +⎝ ⎠ ⎝ ⎠⎝ ⎠ ⎝ ⎠ ⎝ ⎠

1 2 1A r (r r )λ= + −

1 4 1 2 5 2A 2 5 2 B 3 4 3

3 6 3 4 3 4

3 3 13 1 13 1 1

λ γ

λ γ

− −⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟= + − = = + −⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟− −⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟− =⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟−⎝ ⎠ ⎝ ⎠ ⎝ ⎠

P u= λ

0

1

0 1x

y

E1

αE2

Fig. 5.1.8

0

5

10

15

20

25

0 5 10 15 20 25x

y

A

v1

v2

v2

v1 A’

Fig. 5.1.9

0

5

10

15

20

25

0 5 10 15 20 25x

y

r1

A

r2

Pλ(r2- r1)

Fig. 5.1.10

Page 26: Statistical advices for biologists

26 Statistical advices

5.2 Matrix algebra

Biological data bases are most often structured in form of a matrix. Typical examples are our spread-

sheet matrices, for instance using Excel, Access, or Matlab (short for Matrix laboratory). The Excel examples

below show typical biological data sets. Species are in rows and these are described by a set of nominally, ordi-

nally or metrically scaled variables (descriptors). In the first matrix below we have species at four sites and the

values are total catches. In ecology we often have only data about the absence or presence of a certain species.

In this case we deal with presence absence matrices and presences are coded with a 1and absence with a 0.

In general we write matrices in form of rows and columns (Fig. 5.1). An important special case is a ma-

trix that has the same number of rows and col-

umns. This is a square matrix. Matrices with

only one row or one column (row or column

matrices) are vectors. Hence matrices can be

seen as being composed of several vectors.

There are several types of matrices that have

Objects V1 V2 V3 V4 V5A v1,1 v1,2 v1,3 v1,4 v1,5

B v2,1 v2,2 v2,3 v2,4 v2,5

C v3,1 v3,2 v3,3 v3,4 v3,5

D v4,1 v4,2 v4,3 v4,4 v4,5

E v5,1 v5,2 v5,3 v5,4 v5,5

F v6,1 v6,2 v6,3 v6,4 v6,5

G v7,1 v7,2 v7,3 v7,4 v7,5

Descriptors

Species Taxon GuildMean length (mm)

Site 1 Site 2 Site 3 Site 4

Nanoptilium kunzei (Heer, 1841) Ptiliidae Necrophagous 0.60 0 0 0 0Acrotrichis dispar (Matthews, 1865) Ptiliidae Necrophagous 0.65 13 0 4 7Acrotrichis silvatica Rosskothen, 1935 Ptiliidae Necrophagous 0.80 16 0 2 0Acrotrichis rugulosa Rosskothen, 1935 Ptiliidae Necrophagous 0.90 0 0 1 0Acrotrichis grandicollis (Mannerheim, 1844) Ptiliidae Necrophagous 0.95 1 0 0 1Acrotrichis fratercula (Matthews, 1878) Ptiliidae Necrophagous 1.00 0 1 0 0Carcinops pumilio (Erichson, 1834) Histeridae Predator 2.15 1 0 0 0Saprinus aeneus (Fabricius, 1775) Histeridae Predator 3.00 13 23 4 9Gnathoncus nannetensis (Marseul, 1862) Histeridae Predator 3.10 0 0 0 2Margarinotus carbonarius (Hoffmann, 1803) Histeridae Predator 3.60 0 5 0 0Rugilus erichsonii (Fauvel, 1867) Staphylinidae Predator 3.75 8 0 5 0Margarinotus ventralis (Marseul, 1854) Histeridae Predator 4.00 3 2 6 1Saprinus planiusculus Motschulsky, 1849 Histeridae Predator 4.45 0 5 0 0Margarinotus merdarius (Hoffmann, 1803) Histeridae Predator 4.50 5 0 6 0

Species Taxon GuildMean length (mm)

Site 1 Site 2 Site 3 Site 4

Nanoptilium kunzei (Heer, 1841) Ptiliidae Necrophagous 0.60 0 0 0 0Acrotrichis dispar (Matthews, 1865) Ptiliidae Necrophagous 0.65 1 0 1 1Acrotrichis silvatica Rosskothen, 1935 Ptiliidae Necrophagous 0.80 1 0 1 0Acrotrichis rugulosa Rosskothen, 1935 Ptiliidae Necrophagous 0.90 0 0 1 0Acrotrichis grandicollis (Mannerheim, 1844) Ptiliidae Necrophagous 0.95 1 0 0 1Acrotrichis fratercula (Matthews, 1878) Ptiliidae Necrophagous 1.00 0 1 0 0Carcinops pumilio (Erichson, 1834) Histeridae Predator 2.15 1 0 0 0Saprinus aeneus (Fabricius, 1775) Histeridae Predator 3.00 1 1 1 1Gnathoncus nannetensis (Marseul, 1862) Histeridae Predator 3.10 0 0 0 1Margarinotus carbonarius (Hoffmann, 1803) Histeridae Predator 3.60 0 1 0 0Rugilus erichsonii (Fauvel, 1867) Staphylinidae Predator 3.75 1 0 1 0Margarinotus ventralis (Marseul, 1854) Histeridae Predator 4.00 1 1 1 1Saprinus planiusculus Motschulsky, 1849 Histeridae Predator 4.45 0 1 0 0Margarinotus merdarius (Hoffmann, 1803) Histeridae Predator 4.50 1 0 1 0

11 1n

m1 mn

a aA

a a

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

… 11 12 13

21 22 23

31 32 33

a a aV a a a

a a a

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

1

2

3

4

aa

Vaa

⎛ ⎞⎜ ⎟⎜ ⎟=⎜ ⎟⎜ ⎟⎝ ⎠

( )1 2 3 4V a a a a=

Fig. 5.1

Page 27: Statistical advices for biologists

Statistical advices 27

special properties. Let’s first look again to our species x sites matrix. We want to infer whether the site abun-

dances and species occurrences per site are related. In order to do so we use different measures of association

(distance).

Distance measures can operate on presence absence matrices and count site overlap or operate on metri-

cally scaled variables. The simplest count measure is the well known Soerensen index of species overlap (=

Czekanowski index ≈ Jaccard measure):

(5.2.1)

where Sj and Sk are the species number of site j and k and Sjk is the number of shared species.

The general metrically based distance measure that includes the Manhatten (= taxi driver) distance (z =

1) and the Euclidean distance (z = 2) is the Minkowski metric:

(5.2.2)

Other important distance measures are the Bray - Curtis (Czekanowski) metric

(5.2.3)

This metric can be used on raw and ranked data. In ecology the index of proportional similarity of

Colwell and Futuyma is often used

(5.2.4)

where pi,j and pi,k denote the frequencies pi = Ni / Ntotal of species i at sites j and k.

Finally, the Pearson and Spearman correlation coefficients provide measures of distance. This is shown

in Fig. 5.2.1. Data from four sites are cross correlated and give a symmetric 4x4 correlation matrix with diago-

nal elements of one. Such a matrix is the basis for many multivariate statistical techniques.

Association matrices are always square. Square matrices are those with equal numbers of rows and col-

umns. In statistics square matrices are of great importance. A special type of square matrices are diagonal ma-

trices where all elements apart from the diagonal are zero

If all values of a in a diagonal matrix are 1 we speak of a unit or identity matrix

(5.5)

jk

j k

2SD

S S=

+

nzz i, j i,k

i 1

D (x x )=

= +∑

n

i , j i ,ki 1

n n

i , j i ,ki 1 i 1

x xD

x x

=

= =

−=

+

∑ ∑

n

j,k i, j i,k1 1

I 1 0.5 p p=

= − −∑

11

22

33

a 0 0V 0 a 0

0 0 a

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

1 0 0V 0 1 0

0 0 1

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

Page 28: Statistical advices for biologists

28 Statistical advices

Identity matrices are equivalent to the 1 of ordinary numbers.

The transpose matrix A’ is a matrix (m*n) obtained from an original matrix A (n*m) where rows and

columns are changed

A transpose matrix that is identical to the original is square and symmetric

The Figure below shows again important matrix types.

We now start to define matrix operations. First look at a vector, that means a matrix with only one col-

umn (or row). Note that a scalar (a simple number) can be viewed as a vector with only one row or a matrix

with only one row and one column. Further we can view a matrix as a grouping of single vectors. A vector de-

notes a point in space. It length is given by the law of Pythagoras.

(5.2.6)

We see immediately that any vector can be

normalized by dividing its elements through

the length. The new vector will have a length

of 1.

The first operation to introduce is matrix ad-

dition. Assume you have insect counts of 4

species (rows) at 3 sites (columns) during 3

months. This can be formulated in matrix

1 5 91 2 3 4

2 6 10A 5 6 7 8 A '

3 7 119 10 11 12

4 8 12

⎛ ⎞⎛ ⎞ ⎜ ⎟⎜ ⎟ ⎜ ⎟= → =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠

⎝ ⎠

1 2 3 1 2 3A 2 6 10 A' 2 6 10

3 10 11 3 10 11

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟= → =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

1/ 22 2 2

1V 2 L 1 2 3 14

3

⎛ ⎞⎜ ⎟= → = + + =⎜ ⎟⎜ ⎟⎝ ⎠

Site 1 Site 2 Site 3 Site 4Site 1 1.00 0.33 0.56 0.58Site 2 0.33 1.00 0.16 0.69Site 3 0.56 0.16 1.00 0.33Site 4 0.58 0.69 0.33 1.00

Correlation matrix

Site 1 Site 2 Site 3 Site 4

0 0 0 013 0 4 716 0 2 00 0 1 01 0 0 10 1 0 01 0 0 0

13 23 4 90 0 0 20 5 0 08 0 5 03 2 6 10 5 0 05 0 6 0 Fig. 5.2.1

Skalar

Column vector

Row vector

Null vector

Square matrix

3

312

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

000

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

( )3 1 2

11 12 13

21 22 23

31 32 33

a a aa a aa a a

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

Diagonal matrix

Identity matrix (unit matrix)

Symmetric matrix

Orthogonal matrix

Upper triangular matrix

11

22

33

a 0 00 a 00 0 a

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

1 0 00 1 00 0 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

2 4 64 3 76 7 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

3 33 3

⎛ ⎞⎜ ⎟−⎝ ⎠

2 4 60 3 70 0 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

Page 29: Statistical advices for biologists

Statistical advices 29

notation

The total catch per site and species is the sum of the respective matrix elements. We see that matrix ad-

dition is only defined for matrices with identical numbers of rows and columns.

Matrix addition immediately leads to the first type of multiplication, the S-product. We have

I

n other words multiplying a matrix with a scalar means multiplying each matrix element with that sca-

lar. For matrix addition and the S-product hold the commutative, the distributive and the associative laws

The next example introduces the multiplication of matrices. Assume you have production data (in

tons) of winter wheat (15 t) , summer wheat (20 t), and barley (30 t). In the next year weather condition reduced

the winter wheat production by 20%, the summer wheat production by 10% and the barley production by 30%.

How many tons do you get the next year? Of course (15*0.8 + 20* 0.9 + 30 * 0.7) t = 51 t. In matrix notion

this type of multiplication is called a scalar (or dot) product because it results in a number (a scalar in

matrix terminology). In general

(5.2.7)

We can easily extend this example to deal with matrices. We add another year and ask how many cere-

als we get if the second year is good and gives 10 % more of winter wheat, 20 % more of summer wheat and 25

% more of barley. For both yes we start counting with the original data and get a vector with one row that is the

result of a two step process. First we compute the first year value and then the second year value and combine

both scalars in a new row vector with two columns denoting both years.

1 2 3 2 4 0 2 8 1 5 14 42 2 4 1 2 0 7 5 5 10 9 9

A3 5 7 6 9 1 0 0 1 9 14 93 1 0 1 1 4 5 6 1 9 8 5

⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟= + + =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

1 2 3 1 2 3 1 2 3 3 6 9 1 2 3 3 1 3 2 3 32 2 4 2 2 4 2 2 4 6 6 12 2 2 4 3 2 3 2 3 4

A 33 5 7 3 5 7 3 5 7 9 15 2 1 3 5 7 3 3 3 5 3 73 1 0 3 1 0 3 1 0 9 3 0 3 1 0 3 3 3 1 3 0

⋅ ⋅ ⋅⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⋅ ⋅ ⋅⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟= + + = = =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⋅ ⋅ ⋅⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟

⋅ ⋅ ⋅⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

A B B A 1B AA B B AA (B C) (A B) C

A A(A B) A B

A( ) A A

λ λλ λ λ

λ κ λ κ

− = − + = − ++ = ++ + = + +

=+ = ++ = +

( )0.8

P 15 20 30 0.9 15* 0.8 20 * 0.9 30 * 0.7 510.7

⎛ ⎞⎜ ⎟= • = + + =⎜ ⎟⎜ ⎟⎝ ⎠

( )1 n

1 n i ii 1

n

bA B a ... a ... a b scalar

b =

⎛ ⎞⎜ ⎟• = • = =⎜ ⎟⎜ ⎟⎝ ⎠

Page 30: Statistical advices for biologists

30 Statistical advices

Now we consider three sites with different harvest. Recall that species are in columns, sites in rows. We

get an intuitional definition of the scalar or dot or inner product of matrices. The final values give total pro-

duction at three sites and two years. The result is not a scalar but a matrix.

In general we get

(5.2.8)

Hence the dot product can be viewed as a step by step procedure where each row and each column are

subjects to single dot products of two vectors. Further, a dot product is only defined if the number of columns

of A is equal to the number of rows in B. The new matrix has the same number of columns than in B and the

same number of rows than in A. Further, in most cases A• B ≠ B• A. Next, B•B only exists if B is a square ma-

trix.

The above definition implies that if the matrix B is a simple scalar the dot product simplifies to

(5.2.9)

As for scalars we have to look whether the dot product is distributive, associative and commutative. The

dot product is generally not commutative but associative and distributive.

In the case of a symmetric matrix an important relation

exists

(5.2.10)

The trace of a symmetric matrix is defined as the sum of

all diagonal elements of this matrix.

(5.2.11)

( ) ( ) ( )0.8 1.1

P 15 20 30 0.9 1.2 15*0.8 20*0.9 30*0.7 15*1.1 20*1.2 30*1.25 51 780.7 1.25

⎛ ⎞⎜ ⎟= • = + + + + =⎜ ⎟⎜ ⎟⎝ ⎠

15 20 30 0.8 1.1 15*0.8 20*0.9 30*0.7 15*1.1 20*1.2 30*1.25 51 78P 10 15 20 0.9 1.2 10*0.8 15*0.9 20*0.7 10*1.1 15*1.2 20*1.25 35.

5 10 15 0.7 1.25 5*0.8 10*0.9 15*0.7 5*1.1 10*1.20 15*1.25

+ + + +⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟= • = + + + + =⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟+ + + +⎝ ⎠ ⎝ ⎠ ⎝ ⎠

5 5423.5 36.25

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

m m

1i i1 1i iki 1 i 111 1m 11 1k 1 1 1 k

m mn1 nm m1 mk m 1 m k

ni i1 ni iki 1 i 1

a b ... a ba ... a b ... b A B ... A B

A B ... ... ... ... ... ... ... ... ... ... ... ...a ... a a ... a A B ... A B

a b ... a b

= =

= =

⎛ ⎞⎜ ⎟⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟• = • = =⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎜ ⎟⎜ ⎟⎝ ⎠

∑ ∑

∑ ∑

11 1m 11 1m

n1 nm n1 nm

a ... a a c ... a cA B ... ... ... c ... ... ...

a ... a a c ... a c

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟• = • =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

A B B A(A B) C A (B C)(A B) C A (B C) A B C(A B) C A C B C

• ≠ •+ + = + +• • = • • = • •+ • = • + •

(A B) ' B' A '• = •

n

n,ni 1

Tr(A ) aii=

= ∑

Page 31: Statistical advices for biologists

Statistical advices 31

It should be noted that another product of two vectors exist, the outer or cross product. It gives a new

vector that is perpendicular to both original vectors. This product is not used in matrix algebra.

An important transformation of square matrices Ann is the determinant det A or |A|. The determinant is

a scalar that enables to transform matrices A into new ones B. The associated function B = f(A) has to confirm

to three basic rules:

1. B is a linear transformation of A that means

any change in A results in a linear change in

B.

2. Any change in the ordering of rows or col-

umns in A should cause a change of sign in f(A).

3. f(A) is determined by a scalar, called the norm or value of A in such a way that the norm of the

identity matrix is 1. Hence f(I) = 1

The value of a determinant is calculated as the sum of all possible products containing one, and only

one, element from each row and each column. These products receive a sign (+ or -) according to a predefined

rule. The simplest determinant is

(5.2.12)

Determinants have a simple graphical inter-

pretation (Fig. 5.2.2). The area under the parallelo-

gram spanned by the vectors {a1,a2} and {b1,b2} is

identical to the determinant of the matrix A.

Determinants of matrices of higher order

become increasingly time-consuming to be calcu-

lated because we get n! permutations of single prod-

ucts. However with days Math programs this is an

easy task. Above is the respective norm of an exam-

ple matrix calculated by Mathematica.

Why are determinants important? Determinants are used to solve systems of linear equations. They al-

low to infer some properties of a given matrix. Particularly holds

1. If a row or a column of a matrix A is zero det (A) = 0.

2. If a row or a column of a matrix A is linearly dependent on another row or column (is proportional to another

row or column) then det(A) = 0.

3. If a row or a column of A is multiplied by a scalar k to result in another matrix B then det(B) = k det(A).

11 1211 22 12 21

21 22

a aA a a a a

a a= = −

0

5

10

15

20

25

0 5 10 15 20 25

X

Y

a1

b2

b1

a2

Fig. 5.2.2

Page 32: Statistical advices for biologists

32 Statistical advices

If the determinant of a matrix is zero the matrix is called singular. If det A = 0 not all row or columns

are linearly independent. Look for instance at the

next matrices

In P row 2 can be obtained from row one by

the transformation r2 = r1 + 3. However, this is not a linear transformation. In Q, in turn, row 3 is three times

row 2 (row 3 is proportional to row 2). This is a linear transformation and the respective determinant is zero.

Determinants of upper or lower triangular matrices are easy to compute. The determinant of

Triangular distance matrices are important in

multivariate statistics so is the method for comput-

ing the determinant.

For ordinary numbers (scalars) the product

of a number with its inverse gives always 1. Hence

a• a-1 = 1. The extension of this principle to matri-

ces looks at follows

(5.2.13)

To solve this equation we need the inverse of a matrix A-1. We see immediately that this operation is

only defined for square matrices (why?).

It can be shown that the inverse of a matrix is closely related to its determinant

(5.2.14)

The equation tell that an inverse only exists if a matrix is not singular, that is if it has a non-zero deter-

minant. Computing the inverse of a matrix is quite tricky. A formal method provides the Gauß algorithm that

is implemented in standard matrix software. Mathematica calculates inverse matrices with the inverse com-

1 5 0det 2 6 0 0

3 7 0

1 3 5 2 1 5 2det 2 3 6 3 3det 2 6 3

3 3 7 4 3 7 4

⎛ ⎞⎜ ⎟ =⎜ ⎟⎜ ⎟⎝ ⎠

⋅⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟⋅ =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⋅⎝ ⎠ ⎝ ⎠

1 2 3 1 2 3P 4 5 6 ;Q 4 5 6

2 3 1 12 15 18

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟= =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

3

iii 1

1 2 3det( 0 2 4 a 1 2 2 4

0 0 2 =

⎛ ⎞⎜ ⎟− − = = ⋅ − ⋅ = −⎜ ⎟⎜ ⎟⎝ ⎠

1A A I−• =

1

A 0 ... 0 0 1 0 ... 0 00 A 0 0 1 0

1A A ... A I... 1 ...A

0 A 0 0 1 00 0 ... 0 A 0 0 ... 0 1

⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟• = = =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟

⎜ ⎟⎜ ⎟ ⎝ ⎠⎝ ⎠

Page 33: Statistical advices for biologists

Statistical advices 33

mand. We can then check whether the calculation

conforms to our definition of the inverse. Indeed the

dot product of both matrices equals the identity ma-

trix.

Inverse matrices have several important

properties.

1. (B-1)-1 = B

2. B-1•B = B•B-1 = I

3. |B-1| = 1 / |Β|

4. (Α•B)-1 = Β-1 •A-1 ≠ Α-1 •B-1

One important point is that the inverse of a

matrix only exists if |Β| ≠ 0.

How to apply matrices? A first well known examples deals with systems of linear equations. Take

(5.2.15)

Solving the system conventionally gives

(5.2.16)

We see why the determinant was defined in such a curious way. It has to match the requirements for

solving linear algebraic equations. The general solutions for systems with n equations and n unknown variables

Xi is:

(5.2.17)

However, we can make things easier and solve linear systems without using determinants. Assume you

have a system of four linear equations

This system can be written in matrix notation

11 12 1 11 12 1

21 22 221 22 2

a x a y b a a bxa a ba x a y b y

+ = ⎫⎛ ⎞ ⎛ ⎞⎛ ⎞• =⎬⎜ ⎟ ⎜ ⎟⎜ ⎟+ = ⎝ ⎠⎝ ⎠ ⎝ ⎠⎭

1 22 2 12 1 2 11 1 21 2

11 22 12 21 11 22 12 21

1 12 11 11 2

2 22 21 2

b a b a det A b a b a det AX ;Ya a a a det A a a a a det A

b a a bA ;A

b a a b

− −= = = =

− −

⎛ ⎞ ⎛ ⎞= =⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠

ii

AX

A=

1 2 3 4

1 2 3 4

1 2 3 4

1 2 3 4

a 2a a 2a 52a 3a 2a 3a 63a 4a 4a 3a 75a 6a 7a 8a 8

+ + + =+ + + =+ + + =+ + + =

Page 34: Statistical advices for biologists

34 Statistical advices

This equation has the formal structure of A•X=B. Because A-1•A = A•A-1 = I we can multiply both sides

with the inverse of A. We get X = A-1 • B and the solution for the coefficients ai.

The respective Mathematica solution looks

as follows. First we check for singularity. The

determinant of A is -4. Therefore our system

should have a solution. Then we compute the

inverse and in a last step we multiply with the

vector B. We get a1 = -11/4, a2 = 17/4, a3 = -1/4,

and a4 = -1/4. We matrix notation makes solving a

linear system an easy task.

However things are not as easy. First, the inverse matrix has to exist as in our example. If it is singular

no inverse exists and the respective determinant is zero. For non-square matrices we need another feature of

matrices, the rank. Take the next examples of matrices

In A column C is two times column B and the both square submatrices with three rows/columns (the

order of the matrix) have zero determinants. Except of two the 2x2 submatrices have determinants > 0. The

rank is therefore 2. In B both 3x3 submatrices have determinants > 0 and the rank is 3. In C the 2x2 subma-

trices have determinants > 0 and the rank is 2. Hence the rank of a matrix equals the order of the largest subma-

trix whose determinant > 0.

We further need to know what an augmented matrix is. An augmented matrix is a simple combination

of two matrices

The question whether a linear system has solutions is best explained from simple examples.

1 2 3 4 1

1 2 3 4 2

1 2 3 4 3

1 2 3 4 4

1a 2a 1a 1a a1 2 1 2 52a 3a 2a 3a a2 3 2 3 63a 4a 4a 3a a3 4 4 3 75a 6a 7a 8a a5 6 7 8 8

⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟= • =⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠⎝ ⎠⎝ ⎠

11

2

3

4

a 1 2 1 2 5a 2 3 2 3 6a 3 4 4 3 7a 5 6 7 8 8

−⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟= •⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠⎝ ⎠

1 4 8 3 1 5 8 3 1 4 8 3A 2 5 10 5 ;B 2 3 10 5 ;C 2 5 10 5

3 6 12 7 3 1 12 7 0 0 0 0

⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟= = =⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠

11 12 13 11 12 11 12 13 11 12

21 22 23 21 22 21 22 23 21 22

31 32 33 31 32 31 32 33 31 32

a a a b b a a a b bA a a a ;B b b A : B a a a b b

a a a b b a a a b b

⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎜ ⎟ ⎜ ⎟ ⎜ ⎟= = → =⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠

Page 35: Statistical advices for biologists

Statistical advices 35

In the first example we have four unknown variables and four equations. The ranks of A and the aug-

mented A:B are 4. The system has a single solution. In the second case the second equation is simply two times

the first. Therefore we have only three independent equation but four variables. The ranks of A and A:B are

three and therefore less then n, the number of variables. We have infinite solutions. In the third example the

rank of A is three (rows one and two are proportional) but the rank of the augmented matrix is four. In such a

case no solution exists. In the fourth example we have only three equations but four variables. The ranks of A

and A:B are three and less than n. An infinite number of solutions exist. In the last two examples we have more

equations than variables. In the first of these examples the last equations is inconsistent to the previous. The

rank of the augmented matrix is higher than the

rank of A. In turn, in the last example the last

equation is simple two times the previous. It does

not contain additional information. The rank of A

equals the rank of A:B.

In general we can assess whether a linear

system has solutions from the ranks of A and A:B

and the number of variables n (Fig. 5.2..3). A sys-

tem has no solution (is inconsistent) if rank(A) <

rank (A:B). If Rank (A) = n a single solution ex-

1 2 3 4 1

1 2 3 4 2

31 2 3 4

41 2 3 4

1 2 3 4

1 2 3 4

1 2 3

2 x 6 x 5 x 9 x 1 0 x2 6 5 9 1 02 x 5 x 6 x 7 x 1 2 x2 5 6 7 1 2

x4 x 4 x 7 x 6 x 1 4 4 4 7 6 1 45 3 8 5 1 6x5 x 3 x 8 x 5 x 1 6

2 x 3 x 4 x 5 x 1 04 x 6 x 8 x 1 0 x 2 04 x 5 x 6 x

+ + + = ⎫ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎪ ⎜ ⎟ ⎜ ⎟+ + + = ⎪ ⎜ ⎟⎜ ⎟ ⎜ ⎟• =⎬ ⎜ ⎟⎜ ⎟ ⎜ ⎟+ + + = ⎪ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎪+ + + = ⎝ ⎠ ⎝ ⎠⎝ ⎠⎭

+ + + =+ + + =

+ + +

1

2

34

41 2 3 4

1 2 3 4

1 2 3 4

1 2 3 4

1 2 3 4

x2 3 4 5 1 0x4 6 8 1 0 2 0x7 x 1 4 4 5 6 7 1 4

5 6 7 8 1 6x5 x 6 x 7 x 8 x 1 6

2 x 3 x 4 x 5 x 1 0 2 3 4 54 x 6 x 8 x 1 0 x 1 2 4 6 8 1 04 x 5 x 6 x 7 x 1 4 4 5 6 7

5 6 75 x 6 x 7 x 8 x 1 6

⎫ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎪ ⎜ ⎟ ⎜ ⎟

⎪ ⎜ ⎟⎜ ⎟ ⎜ ⎟• =⎬ ⎜ ⎟⎜ ⎟ ⎜ ⎟= ⎪ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎪+ + + = ⎝ ⎠ ⎝ ⎠⎝ ⎠⎭

+ + + = ⎫⎪+ + + = ⎪⎬+ + + = ⎪⎪+ + + = ⎭

1

2

3

4

11 2 3 4

21 2 3 4

31 2 3 4

4

1 2 3 4

1

x 1 0x 1 2x 1 4

8 1 6x

x2 x 3 x 6 x 9 x 1 0 2 3 6 9 1 0

x2 x 4 x 5 x 6 x 1 2 2 4 5 6 1 2

x4 5 4 7 1 44 x 5 x 4 x 7 x 1 4

x

2 x 3 x 4 x 5 x 1 04 x

⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟• =⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎝ ⎠ ⎝ ⎠⎝ ⎠

⎛ ⎞+ + + = ⎫ ⎛ ⎞ ⎛ ⎞⎜ ⎟

⎪ ⎜ ⎟ ⎜ ⎟⎜ ⎟+ + + = • =⎬ ⎜ ⎟ ⎜ ⎟⎜ ⎟⎪ ⎜ ⎟ ⎜ ⎟+ + + = ⎜ ⎟⎝ ⎠ ⎝ ⎠⎭ ⎜ ⎟⎝ ⎠

+ + + =

+ 12 3 4

21 2 3 4

31 2 3 4

41 2 3 4

1 2 3 4

1 2

1 02 3 4 5x

6 x 8 x 1 0 x 1 2 1 24 6 8 1 0x

4 x 5 x 6 x 7 x 1 4 1 44 5 6 7x

1 65 6 7 85 x 6 x 7 x 8 x 1 6x

1 61 0 1 2 1 4 1 61 0 x 1 2 x 1 4 x 1 6 x 1 6

2 x 3 x 4 x 5 x 1 04 x 6 x 8

⎫ ⎛ ⎞⎛ ⎞⎛ ⎞⎪ ⎜ ⎟⎜ ⎟+ + = ⎜ ⎟⎪ ⎜ ⎟⎜ ⎟⎪ ⎜ ⎟ ⎜ ⎟⎜ ⎟+ + + = • =⎬ ⎜ ⎟ ⎜ ⎟⎜ ⎟⎪+ + + = ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎪ ⎝ ⎠⎜ ⎟ ⎜ ⎟⎪+ + + = ⎝ ⎠ ⎝ ⎠⎭

+ + + =

+ + 13 4

21 2 3 4

31 2 3 4

41 2 3 4

1 02 3 4 5x

x 1 0 x 1 2 1 24 6 8 1 0x

4 x 5 x 6 x 7 x 1 4 1 44 5 6 7x

1 65 6 7 85 x 6 x 7 x 8 x 1 6x

3 21 0 1 2 1 4 1 61 0 x 1 2 x 1 4 x 1 6 x 3 2

⎫ ⎛ ⎞⎛ ⎞⎛ ⎞⎪ ⎜ ⎟⎜ ⎟+ = ⎜ ⎟⎪ ⎜ ⎟⎜ ⎟⎪ ⎜ ⎟ ⎜ ⎟⎜ ⎟+ + + = • =⎬ ⎜ ⎟ ⎜ ⎟⎜ ⎟⎪+ + + = ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎪ ⎝ ⎠⎜ ⎟ ⎜ ⎟⎪+ + + = ⎝ ⎠ ⎝ ⎠⎭

1 1 1A X B A A X A B X A B− − −• = → • • = • → = •

Consistent systemSolutions extist

rank(A) = rank(A:B)

Multiplesolutions extist

rank(A) < n

Singlesolution extists

rank(A) = n

Inconsistent systemNo solutions

rank(A) < rank(A:B)

Fig. 5.2.3: Modified from A. K. Kaw (2002): Introduction to Matrix Algebra.

Page 36: Statistical advices for biologists

36 Statistical advices

ists, if rank(A) < n infinite solutions exists. It is easy to show that a system cannot have a finite number of solu-

tions. Assume we have two solutions. We multiply both equations with with the scalars r and 1-r.

We got a new equation of the structure A•Z = B. Hence [rX+(1-r)Y] = Z must be a solution of our initial

system. Because r can be any scalar their must be infinite solutions of A Important is that a solution as in Fig.

3.3 is only possible if we can compute the inverse of A•Z = B. The inverse is only defined for square matrices.

Hence, the number of equations must be identical to the number of variables.

Matrix algebra can also be used to solve algebraic equations. For instance logistic pollution growth fol-

lows a second order algebraic (quadratic) model

At three populations sizes N (1, 5, 10) we got the following rates of increase dN/dt: 5, 25, 8 individuals genera-

tions-1. Now our model looks as follows

rank(A) = rank(A:B) = n. Hence a single solution exists. This is shown above. We se again how simple

it is to solve such a system using math programs. The logistic growth model is

and the respective solution of N(t) is obtained from the solution of the respective differential equation.

The model is a tangens hyperbolicus function (Fig. 3.4) equivalent to the logistic growth equation. E get the

maximum abundance K from the Fig. K = 10.89.

Matrix notation used in this way makes it also easy to compute a linear regression. Assume you have

two sets of data X and Y. This corresponds to a system of linear equations

(5.2.18)

A X B A rX rBA Y B A (1 r)Y (1 r)B

A rX A (1 r)Y rB (1 r)B

A [rX (1 r)Y] B

• = → • =• = → • − = −

↓• + • − = + −

↓• + − =

2dN aN bN cdt

= − + +

2

2

a b c 5 1 1 1 a 5a5 b5 c 25 25 5 1 b 25

100 10 1 c 8a10 b10 c 8

− + + = ⎫ −⎛ ⎞⎛ ⎞ ⎛ ⎞⎪⎜ ⎟⎜ ⎟ ⎜ ⎟− + + = − =⎬⎜ ⎟⎜ ⎟ ⎜ ⎟⎪⎜ ⎟⎜ ⎟ ⎜ ⎟−− + + = ⎝ ⎠⎝ ⎠ ⎝ ⎠⎭

2dN 14 53 14N Ndt 15 5 3

= − + −

1 0 1 1

n 0 1 n

1 10

1n n

Y b b X. . .Y b b X

Y 1 Xb

. . . . . . . . .b

Y 1 X

= + ⎫⎪ →⎬⎪= + ⎭

⎛ ⎞ ⎛ ⎞⎛ ⎞⎜ ⎟ ⎜ ⎟= • ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎝ ⎠⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠

X Y1 22 13 44 35 66 57 88 79 1010 9

Page 37: Statistical advices for biologists

Statistical advices 37

To solve this system we first multiply with the

transpose of X, X’ to get a square matrix X•X’ that can be

inverted. We get the least squares solution of a linear re-

gression

(5.2.19)

We test this approach with a numerical example.

We have ten data pairs {X,Y}. We first calculate the

transpose X’ and then the inverse of the dot product

X’•X. We solve for b by multiplying with (X’•X)-1 and

get the dot products of (X•X’)-1•X’•Y. The result is b0 =

1/3 and b1 = 31/33. Excel computes for the data set b0 =

0.333 and b1 = 0.939. The results are identical. Because

dot products are generally not commutative we have to be

careful about the ordering of matrices.

This approach can easily be extended for instance

to polynomial regression. If you have a regression model of

The respective matrix notation looks as follows

(5.2.20)

The solution is the same as above

(5.2.21)

We try with a slightly modified data set (squared values of Y) and a second order algebraic function Y =

b0 + b1X + b2X2.

Combining all the operations into a single Mathematica task gives b0 = -26/5 = -5.2, b1 = 38/11 = 3.45,

and b2 = 7/11 = 0.636. Excel gives b0 = -5.2, b1 = 3.45, and b2 = 0.636. Again both results are identical. If the

regression is forced to go through the origin (b0 = 0) the first column of X has to be set to zero which is the

same as to leave it. The method can, of course, easily be extended to higher order polynomials and is easy to

compute.

In the tables at the beginning of this section we had typical biological data structures. The descriptors

(the variables) are often correlated. We can construct square matrices that contain information about distances,

1

Y X b X' Y (X' X) bb (X' X) (X' Y)−

= • → • = • • →

= • • •

2 n0 1 2 nY b b X b X ... b X= + + +

1 1

1 1

2 n1 0 1 n

2 nn 0 1 n

n1 1 1 0

nn 1 1 n

Y b b X ...b X

...Y b b X ...b X

Y 1 X ... X b... ... ... ... ... ...Y 1 X ... X b

⎫= +⎪

→⎬⎪= + ⎭

⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎜ ⎟ ⎜ ⎟= •⎜ ⎟⎜ ⎟ ⎜ ⎟

⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎝ ⎠⎝ ⎠ ⎝ ⎠

1Y X b X' Y (X' X) b b (X' X) X' Y−= • → • = • • → = • • •

Page 38: Statistical advices for biologists

38 Statistical advices

for instance correlation matrices. But we can also

construct such matrices that contain covariances.

Covariance measures the joint dispersion of two

variables. The matrix Σ is called the dispersion ma-

trix.

(5.2.22)

Covariance is calculated from

This can be written in vector from

(5.2.23)

[X-μ] is the centralized column vector of the data. Hence to compute the covariance this vector has to be

multiplied by its transpose. The diagonal values σii are of course the respective variances of the variables x.

Another important matrix is the matrix of correlations

(5.2.24)

Because of ρ = σxy/(σxσy) we can introduce a new matrix D that contains only the square roots of the

diagonal values (= standard deviations) of the dispersion matrix. Hence

(5.2.25)

The new matrix Σ is a square matrix and con-

tains the covariances of our variables. This is shown in

the Mathematica example beside. U is a correlation

matrix and S the dispersion matrix containing the stan-

dard deviations of the four variables included. The

result gives a matrix that contains all covariances and

as diagonal values the variances

Next we have to deal with eigenvalues and eigenvectors. Assume we have a matrix A in two dimen-

sional space defining data points in an x,y system (Fig. 5.2.4). We can now define new orthogonal axes u1 and

u2 that minimize the distances δi1 and δi2 to our data points. These new axes (vectors) are called principal axes

of the matrix A. The length of the vectors u1 and u2 are called the eigenvalues λ1 and λ2. Fig. 5.2.5 and 5.2.6

11 1n

n1 nn

...... ... ...

...

σ σΣ

σ σ

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

n

ij ij ij ik iki 1

1 (x )(x )n

σ μ μ=

= − −∑

ij1 [ x ] ' [ x ]n

σ μ μ= − • −

11 1n

n1 nn

...... ... ...

...

ρ ρΡ

ρ ρ

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

1 1D D D DΡ Σ Σ Ρ− −= • • → = • •

Page 39: Statistical advices for biologists

Statistical advices 39

also show how to interpret eigenvalues and eigenvectors. Assume our data points to be enclosed by an ellipse.

The longer diagonal marks the first eigenvector. The longer this vector is the closer scatter the data points along

this vector. Hence λ is a measure of how well the principal axis describes our data matrix.

Eigenvalues λι and eigenvectors ui are connected to the matrix A in such a way that the dot product of

A•ui gives ui multiplied with λ. Hence

(5.2.26)

Eq, 5.26 can be transformed to

(5.2.27)

Eq 5.25 might be interpreted as follows. How long do I have to stretch the vector u to get a new matrix

a•u from A. Introducing eq. 5.25 we get

(5.2.28)

For any two principles axes vectors ui and uj the covariance s(ui, uj) becomes

(5.2.29)

becomes the dot product of orthogonal vectors is zero. The last two equations are of great iportance. They tell

that (a) principal axes are independent and (b) that the

eigenvalues tell how much of total variance is

explained by a given principal axis (eigenvector). Sev-

eral methods of ordination and grouping for instance

use this technique to reduce the number existing inter-

correlated variables in such a way that new composite

variables appear that are not correlated. The variables

are defined by the principle axes and the goodness of

fit is given by the associated eigenvalues. The general

idea is to get a small number of independent variables

that are easy to interpret.

i i iA u uλ• =

i i i i i i i iA u u A u u 0 [A I] u 0λ λ λ• = → • − = → − • =

T U ' U U ' UΣ λ λ λ= • = • =

i j i j j j i js(u , u ) u ' u u ' u 0λ λ= • = • =

-80

-60

-40

-20

0

20

40

60

80

-60 -40 -20 0 20 40 60

X

Y

δi1

δi2

u1

u2

Fig. 5.2.4

x

y

λu1

u1

x

y

λu1

u1

Fig. 5.2.5 Fig. 5.2.6

Page 40: Statistical advices for biologists

40 Statistical advices

Eq. 5.2.26 is of course solved by a null vector u. The

equation is also zero if det (A-λiI) = 0. This property gives

a solution for λi. In other words we are looking for such a

λ that makes (A-λI) to a vector that is orthogonal to u. An

example. For the matrix A = {{2,1},{3,4} we need

W get the associated eigenvectors from both λ values by

solving

We check

However these vectors are not orthogonal. u1•u2 ≠ 0. However, one special type of matrices gives or-

thogonal eigenvectors. These are symmetrical matrices. Symmetrical matrices are often used in biology. These

are for instance most association and all dispersion matrices where Dij = Dji. The diagonal elements are 1. Look

at the next Mathematica solution. A symmetrical association matrix has orthogonal eigenvectors. We check for

this by multiplying both. The result is zero. The Fig. 5.2.7 shows both eigenvectors. They are indeed orthogo-

nal. Hence symmetrical matrices have orthogonal eigenvectors.

The Mathematica example beside shows a numerical example of eq. 5.26. The dot product of a matrix A

with its eigenvector is identical to the multiplication of the eigenvector with its eigenvalue. Further, it holds

that means the matrix of eigenvectors U transposes a matrix A into the matrix of eigenvalues Λ.

How to calculate principal axes ? With

some mathematics one can show that

(5.2.30)

with Σ being the dispersion matrix and [x-μ]

the matrix of xi-μ values for each variable.

This equation has the same structure as the

equation of the eigenvectors (5.26). Hence

[x-μ] is one of the eigenvectors of Σ. We

take a simple example of two variables x

1 1

2 1 1 0 2 10 0

3 4 0 1 3 4

(2 )(4 ) 3 1; 5

λλ

λ

λ λ λ λ

−⎛ ⎞ ⎛ ⎞− = → = →⎜ ⎟ ⎜ ⎟ −⎝ ⎠ ⎝ ⎠

− − = → = =

1 21 1

2 2 1 2

(2 )u u 0u u2 1 1 0 2 1 1 10 0 u

u u3 4 0 1 3 4 3u (4 )u 0 1 3− + =− −⎫⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞

− • = → • = → → =⎬⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟− + − =⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎝ ⎠ ⎝ ⎠ ⎭

λλλ

λ λ

2 1 1 1 11

3 4 1 1 1

2 1 1 5 15

3 4 3 1 5 3

− − −⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞• = =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞

• = =⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠ ⎝ ⎠ ⎝ ⎠

A U U Λ• = •

( I)[x ] 0Σ λ μ− − =

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

-0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8x

y (0.7,0.7)(-0.7,0.7)

Fig. 5.2.7

Page 41: Statistical advices for biologists

Statistical advices 41

and y and want to calculate the principle axies. We need

the dispersion matrix that contains the covariances. The

variance of X is sx2 = 20, of y sy

2 = 25.03, and the

covariance is sxy = 16.73. We compute the eigenvalues

and eigenvectors of S and get the first eigenvector E = {-

0.65, -0.76}. The principal axis slope is therefore m = -

0.76/-0.65 = 1.16. From y = mx + b we get the intercept b

= -3.64 (Fig. 5.2.8). We performed a major axis

regression.

The solution is given in beside. We need the

dispersion matrix Σ and compute the

eigenvectors and eigenvalues. The eigenvalue

λ is identiccal to the λ of eq 4.12 of the major

axis regression. In general we get the

slope m of the major axis regression

from the values y / x of the first

major axis, that means the axis of the

largest eigenvalue.

(5.2.31)

This result is identical to eq. 4.11. We check m = 16.73/(39.42 - 25) = 1.16.

How to get the dispersion matrix Σ? In our

case this is the matrix of covariances. The Excel

example beside shows that we need the matrix of

[x—m] centralized vectors of X and Y. The dot

product of this matrix with its transpose gives the

requested dispersion matrix.

Another application of eigenvectors and eigenvalues. For Markov chains it is often necessary to calcu-

late the power of a matrix An. We got the diagonal matrix L from A•U=Λ•U=U•Λ. Look at the example below.

We see that A•U = U•Λ with U being the matrix of eigenvectors and Λ the diagonal matrix of eigenvalues. We

( )

xy

2 2 2 2 2 2x y x y xy

2 2 2 2 2 2 2 2 2 2 2 2x y x y xy y x x y xy

xy2y

2sm

s s (s s ) 4s

1 s s (s s ) 4s 2 s s (s s ) 4s2

sm

s

=+ − + − −

λ = + + − − → λ− = + − −

=λ−

y = 1.16x - 3.64

-505

101520

0 5 10 15X

Y

Fig. 5.2.8

X Y 2 3 3 4 4 1 5 5 6 2 7 6 8 3 9 8

10 4 11 9 12 4 13 10 14 9 15 15 16 19

X Y X- Y-Data 1 2 -2 -1.71 -2 0 -1 2 -1 3 -1

3 4 0 0.286 -1.71 0.286 -0.71 2.286 -1.71 4.286 -2.712 3 -1 -0.715 6 2 2.2862 2 -1 -1.716 8 3 4.2862 1 -1 -2.71

Mean 3 3.714 0 0 X'.X 20 26StDev 1.69 2.312 1.69 2.312 26 37.43Variance 2.857 5.347 2.857 5.347

1/n X'.X 2.857 3.714Covariance 3.714 3.714 5.347

Transpose

Page 42: Statistical advices for biologists

42 Statistical advices

get a simple way to compute the power of a matrix

(5.2.32)

We need the matrix of eigenvectors, its inverse and the vector of eigenvalues where each element λi is

raised to power n.

A next important property is that the determinant of a square matrix is identical to the product of its ei-

genvalues.

(5.2.33)

Hence a determinant is zero if at least one of its eigenvalues is zero.

( )

1

n 1 1 1

n 1 1 n 1 n n 1 n 1i i

A U U A U UA (U U )(U U )(U U )...

A U ( U U) U U U U I U U U

Λ Λ

Λ Λ Λ

Λ Λ λ λ

− − −

− − − − −

• = • → = • • →

= • • • • • • →

= • • • • = • • = • • • = • •

n

n n ii 1

P λ=

= ∏

Page 43: Statistical advices for biologists

Statistical advices 43

6. Multiple regression

Surely, the most often used statistical tool of biologists is regression analysis. Multiple regression is the

generalization of simple linear regression where you try to predict one dependent variable from a second in-

dependent variable. In multiple regression you have again one dependent but now a set of n independent vari-

ables. In mathematical terms

(6.1)

Recall that X and Y are series of observations. Hence, we can write them in vector notation

(6.2)

We solve this equation as before and take care of the ordering of elements.

(6.3)

Let’s take a simple example. Three predictor (independent) variables X are assumed to influence the

dependent variable Y. The complete multiple regression needs two lines of programming and the output gives

us the parameters b0 = 0.54, b1 = -0.21, b2 = 0.23, and b3 = -0.006. Our regression model looks as follows

The previous model used raw data. Now we take a slightly different approach. We standardize our vari-

ables and use the common Z-transformation. Recall that Zi = (Xi-μ)/σ with Z having a mean of 0 and a standard

deviation of 1. The regression model looks as follows

0 1 1 2 2 3 3 01

...=

= + + + + + = + ∑n

n n i ii

Y b b X b X b X b X b b X

1,1 1,k1 0

2,1 2,k2 1

n 1,1 n 1,kn 1 n 1

n,1 n,kn n

1 x ... xy b1 x ... xy y1 ... ... ...Y X b... ...1 x ... xy b1 x ... xy b

− −− −

⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟= = • = •⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟

⎜ ⎟ ⎜ ⎟⎜ ⎟⎝ ⎠ ⎝ ⎠⎝ ⎠

1Y X b X' Y (X' X) b b (X' X) (X' Y)−= • → • = • • → = • • •

1 2 30.54 0.21 0.23 0.006= − + −Y X X X

Y X1 X2 X3 0.78 1.10 1.51 1.37 0.73 2.84 3.35 4.24 0.87 3.43 3.72 4.76 0.55 1.97 2.90 3.27 0.81 0.29 0.72 1.01 0.26 1.52 1.32 2.04 0.65 2.85 3.53 4.11 0.76 2.83 3.46 4.69

Page 44: Statistical advices for biologists

44 Statistical advices

(6.4)

Applying equation 3 we get

(6.5)

How to interpret ZXZX’ and ZX’ZY? Look at the definition of the coefficient of correlation:

(6.6)

This is a very important equation that tells that a coefficient of

correlation is the sum of all pairwise Z-values of X and Y. Now

look at the ZX’ZY matrix. This is nothing else that this sum calcu-

lated for all X variables. For the ZX’ZX matrix holds the same. It is

identical to the correlation matrix for all X. Hence we can write

(6.7)

.From this identity we get a new simple equation for the multiple regression.

(6.8)

Where R denotes the respective correlation matrices. The Mathematica solution for the example in the

previous table is shown below. Our model is

This result based on Z-transformed data differs from the above that was based on raw data. In the latter

case we got standardized correlation coefficients, so-called beta values.

Our multiple regression tries to predict the values of the dependent variable on the basis of the inde-

0 1 1 2 2 3 3 01

...=

= + + + + + = +∑n

Y X X X n Xn i Xii

Z b b Z b Z b Z b Z b b Z

1Y X X X X X X X YZ Z b Z 'Y (Z ' Z )b b (Z ' Z ) (Z ' Z )−= → = → =

n

i i n ni 1 i i

X Yi 1 i 1X Y X Y

(X X)(Y Y)(X X) (Y Y)1 1 1r Z Z

n 1 s s n 1 s s n 1=

= =

− −− −

= = =− − −

∑∑ ∑

n n

X1 X1 X1 Xki 1 i 1 X1X1 XkX1

n nXkX1 XkXk

Xk X1 Xk Xki 1 i 1

1 1Z Z ... Z Zr ... rn 1 n 1

... ... ... ...r ... r1 1Z Z ... Z Z

n 1 n 1

= =

= =

⎛ ⎞⎜ ⎟− − ⎛ ⎞⎜ ⎟ ⎜ ⎟=⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟

⎝ ⎠⎜ ⎟⎜ ⎟− −⎝ ⎠

∑ ∑

∑ ∑

1XX XYR Rβ −=

1 2 30.71 1.08 1.20 0.03= − − + −Y X X X

Mean 0.67625 2.10375 2.56375 3.18625 StDev 0.1949313 1.071793 1.18694 1.514567

Y X1 X2 X3 Z(Y) Z(X1) Z(X2) Z(X3) 0.78 1.1 1.51 1.37 0.532239 -0.93651 -0.88779 -1.19919

0.73 2.84 3.35 4.24 0.275738 0.686933 0.662418 0.695744 0.87 3.43 3.72 4.76 0.99394 1.237412 0.974144 1.039076 0.55 1.97 2.9 3.27 -0.64766 -0.12479 0.283291 0.055296 0.81 0.29 0.72 1.01 0.686139 -1.69226 -1.55336 -1.43688 0.26 1.52 1.32 2.04 -2.13537 -0.54465 -1.04786 -0.75682 0.65 2.85 3.53 4.11 -0.13466 0.696263 0.814068 0.60991 0.76 2.83 3.46 4.69 0.429639 0.677603 0.755093 0.992858

Page 45: Statistical advices for biologists

Statistical advices 45

pendent variables. However, the model does not tell anything about the goodness of fit. In ordinary regression

this measure is the coefficient of determination R2. R2 is defined as the proportion of variance in Y that is ex-

plained by the model. Using the model with Z-transformed data we get

(6.9)

where k is the number of independent variables. Hence R2 equals the sum of all Z-transformed predicted values

divided through the number of cases n. In a last step we need information whether the grand R2, the model wide

coefficient of variation and the beta values of each model variable explains a significant part of total variance.

In order to do this we have two possibilities. First we can use standard F and t tests. Hence

(6.10)

with f being the degree of freedom. The standard error of beta is computed from

(6.11)

with rii (V-1)being the element ii of the inverted association matrix V and n the number observations and k the

number of independent variables in the model. The significance of the whole model (the significance of R2) is

tested by an F-test.

(6.12)

Both tests assume normally distributed errors and are only approximations. Today standard errors are

most often obtained from permutation tests. Hence the values Xi of the predictor variables are randomly re-

shuffled and after each such reshuffling a new multiple correlation is computed. This method gives a range of

different beta values for each predictor variable. The distribution of values gives then the required standard

error of beta.

The Table below presents a typical problem biologists are faced with. We got data about abundances of

( ) pred

n n2 2pred pred k

2 1 1i Yi2

1Z( Y )

Z Z Z1R r

n 1 s n 1β

−= = =

− −

∑ ∑∑

beta( )Standard error beta

=t f

1 2ii

ir (V )(1 R )SE( )

n k 1β

− −=

− −

2

2

R n k 1F(1 R ) k

− −=

Andricus curvator Torymus sp. Charips sp. Height Temperature Precipitation Competi-tors Andricus prev. Gen.

0.572 0.000 0.000 0.041 0.690 0.842 1.841 2.227

0.983 0.304 0.038 0.646 1.211 0.443 1.143 3.245

0.654 0.961 0.875 1.948 1.294 0.585 1.456 2.181

0.579 0.066 0.023 0.230 1.439 0.680 0 2.074

0.329 0.291 0.266 0.623 1.263 0.471 1.901 1.908

0.335 0.097 0.061 0.292 0.836 0.619 1.257 2.321

0.295 0.139 0.019 0.278 0.476 0.015 1.245 1.476

0.404 0.761 0.433 1.583 1.240 0.556 1.669 1.715

0.506 0.129 0.100 0.307 0.885 0.444 1.728 2.527

0.127 0.606 0.452 6.147 0.860 0.932 0.192 0.727

Tab.1: Data set of the gall wasp example.

Page 46: Statistical advices for biologists

46 Statistical advices

the gall inducing hymenopteran insect Andricus curvator, a small cynipid wasp, which induces large galls in

the leaves of oaks. We are interested too see on which factors numbers of galls depend. We got data about two

competing wasp species, Neuroterus albipes and Cynips quercusfolii, and the parasitic wasps Torymus sp. and

Charips sp. Additionally, we have data about precipitation and temperature during the sampling period. At last

we speculate that the height of the galls (in m) and the abundance of Andricus in the previous generation might

influence the actual gall densities. From this we make a model that contains one dependent variable, (Andricus)

and seven independent variables. In total we have 10 observational data sets (cases) (Tab. 1).

Now we take a common statistical package and copy our data to the package spreadsheet and run the

multiple regression option with all default settings. We get Tab. 2 and are lucky. The multiple regression points

to highly significant predictor variables. Only temperature seems to be unimportant.

The output contains a number of important metrics. First it gives a multiple regression coefficient of

correlation R, in analogy to the simple Pearson coefficient. It denotes the fraction of total variance explained

by the model R2, as well as a corrected level of variance that corrects for small sample size corr R2 (correction

for shrinkage after Carter). The significance level (the probability to make a type I error) is computed by an

ordinary F-test. Next we have the predicted model parameters B and the beta-values. Note that beta and b-

values are connected by the following equation.

(6.13)

where s again denotes the standard deviation of variables Xi and Y.

In the case of only two variables beta-values are identical with the Pearson coefficient of correlation.

The output contains also standard errors of the parameters. Be careful, standard errors not standard devia-

tions. All multivariate statistics give standard errors. For t-tests or other pairwise comparisons instead you

need standard deviations. Don’t use the errors of regression analysis unconsciously for further analysis, for

instance for tests whether coefficients of correlations or slopes of two models differ. Because standard errors

are always lower than standard deviations you would get highly significant results even where no such are. The

t-test at the end of the table tests whether the beta-values differ significantly from zero.

We should undertake a stepwise regression analysis. That means we should step by step eliminate all

variables from our regression that are not significant at a given p-level (this is in most cases the 5% error level).

( )( ) ( )( )

ii i

s Xbeta X B Xs Y

=

Regression results Andricus curvator R= .99249221 R2= .98504080 Corr. R^2= .93268358 F(7,2)=18.814 p<.05139 St. error estimate: .08486 St. Error St. Error BETA BETA B B t(2) p Constant -0.11087343 0.06868625 -1.614201 0.247836247 Torymus sp. 13.7927381 1.73 9.47414806 1.19037895 7.958934 0.015422399 Charips sp. -0.59362267 0.13 -0.53016972 0.11920767 -4.447446 0.047019567 Height -12.88380312 1.7 -4.4568535 0.58641288 -7.600197 0.016875148 Temperature 0.055252508 0.09 0.03653174 0.06261583 0.583427 0.618633568 Precipitation 0.401934744 0.08 0.38702041 0.07298097 5.303032 0.033768319 Competitors -0.430314466 0.07 -0.13810155 0.02118692 -6.518245 0.022736695 Andricus p. G. 0.719259319 0.06 0.33336712 0.02673744 12.46818 0.006371302

Tab.2: First multiple regression results of the gall wasp example.

Page 47: Statistical advices for biologists

Statistical advices 47

Stepwise regression throws out Temperature and gives us a model where all independent (predicator) variables

are significant at the 5% error level. It seems that we can prepare a paper.

Really? In this short example we made a whole set of errors. We applied a method without prior check-

ing whether the prerequisites of the method are met. In fact, the data of Tab. 1 are nothing more than simple

random numbers or combinations of random numbers. How is it possible to get highly significant results with

them?

A multiple regression relies on the general linear model (GLM). Hence it must be possible to formu-

late the whole regression model as a linear combination of variables. The variables must be connected by

6.1 How to interpret beta-values An important but also difficult problem in multiple regression is the interpretation of beta-values. Remember

that

Remember also that the coefficient of correlation for a simple correlation between two variables is defined as

It is immediately evident that beta-values are generalisations of simple coefficients of correlation. However,

there is an important difference. The higher the correlation between two or more predicator variables

(multicollinearity) is, the less will r depend on the correlation between X and Y. Hence other variables might

have more and more influence on r and b. For high levels of multicollinearity it might therefore become more

and more difficult to interpret beta-values in terms of correlations. Because beta-values are standardized b-

values they should allow comparisons to be make about the relative influence of predicator variables. High

levels of multicollinearity might let to misinterpretations.

Hence high levels of multicollinearity might

• reduce the exactness of beta-weight estimates

• change the probabilities of making type I and type II errors

• make it more difficult to interpret beta-values.

There is an additional parameter, the so-called coefficient of structure that we might apply. The coefficient of

structure ci is defined as

where riY denotes the simple correlation between predicator variable i and the dependent variable Y and R2 the

coefficient of determination of the multiple regression. Coefficients of structure measure therefore the fraction

of total variability a given predicator variable explains. Again, the interpretation of ci is not always unequivocal

at high levels of multicollinearity .

( )( ) ( )( )

ii i

s Xbeta X B Xs Y

=

X

Y

sr bs

=

2iY

ircR

=

Page 48: Statistical advices for biologists

48 Statistical advices

linear regressions of the type Y = aX + b. We check this and don’t detect any significant deviation from linear-

ity. In fact, however, I computed the previous generation data of A. curvator as a power function with random

offset from the A. curvator data. We did not detect this because we have only ten observations and the range of

values is too small to detect deviations from linearity. This leads us immediately to a second major error. We

have eight variables but only ten observations. The number of cases is much too low. A general rule is that the

number of data sets should be at least 2 times the number of variables included in the original model. In

our case we must reformulate our initial model to include at most four variables.

There is a simple equation to compute the optimal sample size n (although in reality we will seldom

have the opportunity to have such large sample sizes. Instead, we will most often only deal with minimal sam-

ple sizes.

(6.14)

where R is the desired experiment wise coefficient of determination (explained variance). This value depends

on what we intend to accept as a significant difference, the effect size. We know effect sizes already from

bivariate comparisons and the discussion of the t-test. R2 and effect size ε2 are related by the following equation

(6.15)

For ε2 = 0.02 (week effect) R2 = 0.02; ε2 = 0.15 (medium effect) R2 = 0.13; for ε2 = 0.35 (strong effect) R2 =

0.26 The L values that can be obtained from the following Table

If we have for instance 5 variables in the model and want to have a multiple R2 value of 0.95 we need 35 data

sets to see a strong effect.

If we find non-linear relationships between variables we have to linearize them, for instance by appro-

priate logarithmization. But be careful. Logarithmization changes the distribution of errors around the mean.

The GLM but relies on the assumption that the errors are distributed normally around the mean, and that they

are not correlated with the dependent variable. They have to be homoscedastic. Otherwise we speak of heter-

scedasticity.

A good example is Taylor’s power law. Insects, for instance fluctuate in abundance. Assume we study

ten species with different upper limits of abundance, different carrying capacities. Insight these boundary

abundances fluctuate at random. This is a typical statistical process called proportional rescaling. For such a

process it is easy to show that mean and variance are connected by a simple equation

(6.16)

Read: The variance is proportional to the square of the mean. Hence the variance, the distribution of errors

around the mean, rises linearly with the squared mean. Mean and variance are correlated. This violates the

assumptions of the GLM. Fortunately, the model is very robust against this type of correlation. The B– and beta

values are nearly unaffected but the error levels p might be distorted. In non-linear relationships variances and

2

2

(1 )L RnR−

=

22

21R

Rε =

2Variance mean∝

Variables 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 25

L 7.8 9.7 11.1 12.3 13.3 14.3 15.1 15.9 16.7 17.4 18.1 18.8 19.5 20.1 20.7 22.5 23.1 23.7 24.3 25.9

Page 49: Statistical advices for biologists

Statistical advices 49

means are often correlated.

Next the errors around the mean must not be correlated with each others. They must not be autocorre-

lated. Be careful at high levels of autocorrelation. All statistical packages contain a simple test for autocorrela-

tion, the Durbin-Watson test for serial correlation D. Without going into the details I tell that D-values

around 2 indicate low levels of autocorrelation. In our example D is 2.93. This high value points to severe auto-

correlation and we have to check our data which of the variables causes this problem. We have to eliminate the

variable from the initial model. Another method to detect violations of the GLM assumptions is a visual inspec-

tion of the residuals. Residuals are the deviation of the data from the regression line and are often used for fur-

ther analysis. Residuals should be normally distributed around the mean (the value of the regression line). Any

regularities in the distribution of residuals hence point to heteroscedasticity or autocorrelation and therefore

to an incorrect use of multiple regression. However, as already stressed, multiple regression is a quite robust

method and only severe distortions of the residual distribution make the results unreliable.

It’s still unclear why we got highly significant results from random data. The first answer is that some of

the predicator variables were highly correlated. Height and Torymus were highly correlated (R2 = 0.99). This

violates the assumption of the GLM. Although multiple regression is a technique designed to detect interrela-

tions between sets of predicator variables pairwise correlations must not be too high. In other words they

must not explain the same part of variance. If they were perfectly correlated a multiple regression would be

impossible. Technically speaking the matrix of correlation coefficients would be singular and the inverse would

not be defined. Including such variables would also give evidence of an ill designed model. That something is

wrong with the variables Height and Torymus is also indicated by the values of beta. As coefficients of correla-

tion, beta-values should range between –1 and 1. The above equation however tells that absolute values larger

than one are possible. However, very high or low values of beta often indicate some violation of the GLM

assumptions.

A next answer lies in the distinction between test wise and experiment wise error rates. What does

this mean? If you test whether single variables are significant or compare two means you perform a test and

have a probability to make a type I error (your significance level). However, if you test a whole model (the

outcome of an experiment) you have to perform a series of single tests and you get a type I error level that re-

fers to the whole experiment. In our case we got 8 test wise error levels and one experiment wise multiple R2

with p(t) < 0.051. If you accept a single test at p < 0.05 and perform n tests your probability to get at least one

significant result is

(6.17)

(why?). Hence, for n = 7 you get p = 0.30, a value much higher than 0.05. This means for our example that the

probability to get at least one significant result out of seven predictor variables is nearly 30%. In a multiple

regression this value is even too low because you have to consider all combinations of variables. Additionally,

the lower the number of observations is, the higher is the probability for a significant result (why?). Hence to

be sure to make no error you have to reduce your test wise error rate to obtain an experiment wise error rate of

less than 0.05. The most easiest way to do this is to use a so-called Bonferroni correction obtained from the

first element of the Taylor expansion of eq. 16. You simply divide your test wise error rate α by the number of

variables in the model

1 (1 0.05)np = − −

Page 50: Statistical advices for biologists

50 Statistical advices

(6.18)

In our example of the first table you should accept only variables with p < 0.05 / 8 = 0.006. Hence, only

the previous generation of A. curvator remains in the model. This correction should always be used in multi-

variate statistics.

Let us at the end assume that the data of Tab. 1 where real. We can then redefine our initial model to

perform a correct multiple regression. First, we have to reduce the number of variables. By this we also define a

logical model that we want to test with the regression analysis. Our data contain three groups of variables.

Torymus and Charips are parasitoids or inquilines of Andricus. We simply combine both variables and use a

new variable ’parasitoid abundance’ as the sum of both. By this we also reduce the degree of multicollinearity

in the data set because Torymus and Charips abundances are highly correlated. We also have two variables that

describe weather conditions. They are not correlated. We define the precipitation / temperature ratio P/R, the

hydrothermic coefficient, as a new variable that describes moisture. Low values indicate rather dry periods,

high values moist conditions. Height was highly correlated with Torymus. At the moment we have no good

explanation for this pattern and skip the variable height. We would have to undertake further experiments to

clear this point.

With this variables we undertake a new regression analysis and find only the competitors to be signifi-

cant. The Durbin-Watson statistics gives a value of D = 2.07. We do not expect higher levels of autocorrelation.

We drop the other variables and get at the end a simple linear regression between Andricus and its competitors

(Andricus = (0.39 ± 0.09)Competitors - (0.33 ± 0.19); R2corr. = 0.69; p < 0.002. Note that the errors are

standard errors not standard deviations. The p-value is smaller than our Bonferroni corrected acceptable

error level of 0.006 and we might accept the hypothesis about a close relation between Andricus and Cynips

abundances. But be careful. Both data sets consist of pure random numbers. I needed only five reshuffles to get

the data matrix for this result. The example shows how easy it is to get highly significant results from nothing.

Multiple regression uses ordinary least squares and relies on coefficients of correlation as distance meas-

ure. But recall the basic model to calculate the regression

(6.19)

The model contains two association matrices. We might use other measures of distance to get different

regression models. For instance look at the next table. It gives the occurrences of 12 species at five sites. This is

a presence-absence table. Does the occurrence at sites two to five

predict the occurrence at site one? We use the Soerensen index and

get the respective association matrix. With this matrix we run a

multiple regression and get the respective beta values and the in-

verse of R. This is enough to

calculate the coefficients of

determination and signifi-

cance levels using equations

8 to 11. The matrix below

*nαα =

1XX XYR Rβ −=

Site 1 Site 2 Site 3 Site 4 Site 5 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0

1 2 3 4 5 1 1.00 0.86 0.67 0.77 0.6 2 0.86 1.00 0.67 0.62 0.86 3 0.67 0.67 1.00 0.36 0.83 4 0.77 0.62 0.36 1.00 0.62 5 0.68 0.86 0.83 0.62 1.00

Page 51: Statistical advices for biologists

Statistical advices 51

shows the results and the calculations.

We see that none of the single predic-

tors is statistically significant. The rea-

son for the low t-values is that the

numbers of species (cases) used is too

low. The regression used in this way

has a week power that means it too

often favours the null hypothesis of no

influence. For a sound regression

model we needed at

least 50 species.

The whole model, in

turn, appears to be

significant before

Bonferroni correction.

The Bonferroni cor-

rected significance

level would be 0.09. Hence despite the high R2 value of 0.87 (calculated from the beta values and the respec-

tive correlation coefficients according to eq. 6.9) we infer that the predictor variables do not allow for a predic-

tion of site occurrences at site one. Again the reason for this discrepancy is the too low number of cases.

We used a multiple regression approach of presence absence data associated with the Soerensen index.

Important is that we run a multiple regression of nominally scaled data. Indeed, we can even used mixed mod-

els with nominally, ordinary and metrically scaled variables. Important is that we have to be able to use the

same association measure for all of these data types. Often we have to apply a previous classification. Impor-

tant is also that we do not get regression equations to predict occurrences. We only infer significant influences.

R2 0.8707 =AT29*AV29+AT30*AV30+AT31*AV31+AT32*AV32 Site J rii beta ST error t p

2 0.86 4.06 0.36 1.217071 0.295792 0.777359 3 0.67 3.7 0.09 0.318726 0.282374 0.787145 4 0.77 1.91 0.36 1.774444 0.202881 0.845933 5 0.86 8.14 0.26 0.62078 0.418828 0.689921

=AV32/(AU32*(1-$AT$27)/6)^0.5 F p 8.080742 0.018335

=AT27*6/((1-AT27)*5)

Page 52: Statistical advices for biologists

52 Statistical advices

6.2 Advices for using multiple regression: • First of all, multiple regression is a tool for testing predefined hypotheses. It is not designed for

hypothesis generating. Hence the first thing you must do is to formulate a sound model of how

your variables might be related. A blind pattern seeking will often lead to erroneous results be-

cause with a sufficient number of variables and small sample sizes you will very often if not al-

ways find some ‘significant’ dependencies.

• Thing hard about cause and effect. In many cases it is not obvious which variable is the depend-

ent and which the independent. In many cases a path diagram helps in formulating logical hy-

potheses.

• All variables must have a metric scale.

• Prior to computation check the correlation matrix of all single correlations. Eliminate independ-

ent variables that will not explain any part of total variance because they fully or nearly fully

depend on another variable (multicollinearity). As a rule eliminate them if they are correlated

with another independent variable with r > 0.9.

• Check for non-linear dependencies and try to eliminate them. Often logarithmic rescaling of

some or all variables gives better results.

• In cases of heavy violations of the assumptions of the GLM use non-parametric regression. In its

simplest form use ranked variables.

• The number of observations N must be sufficiently large. N should be at least twice the initial

number of variables in the model.

• After computing the regression check for autocorrelation (using the Durbin-Watson static; D

should be between 1 and 3) and inspect visually the distribution of residuals. These should not

show any regularities. Patterns in the distribution of residuals indicate violations of the general

linear model.

• At small data set size use always Bonferroni corrected significance levels

• Use a stepwise analysis and eliminate in a stepwise manner all variable that do not significantly

explain parts of total variance.

• Check the resulting multiple regression equation whether it is sound and logical.

• Try to check the resulting equation using other data. This leads often to an improvement of the

original model.

• If you have a large number of observations (data sets) divide the data set prior to computation at

random into a part with which you generate your multiple regression equation and a part with

which to test this equation. If your test leads to unsatisfactory results you have to reformulate the

whole model and start again. This means often that you have to include other previously not con-

sidered variables.

• A last step should be the verification of the model by other independent data sets.

Page 53: Statistical advices for biologists

Statistical advices 53

6.3 Path analysis and linear structure models

Multiple regression requires a predefined model that shows relationships between vari-

ables. At least it must be possible to define dependent and independent variables. How

do we know which of the variables is dependent? We need some prior knowledge or

assumptions about causal relations. With four predictor variables our model looks as

follows. E denotes the unexplained part of total variance.

Path analysis tries to generalize our assumptions about causal

relationships in our model. Now we also try to establish the causal

relations between the predicator variables. We define a whole model

and try to separate correlations into direct and indirect effects. A

path analytical model might look as follows: X1 to X4 are the pre-

dictor variables, Y is the predicant (the dependent variable) and e

denote the errors (the unexplained variance) of each single variable.

The aim of path analysis is now to estimate the correlation coeffi-

cients between all variables and the amounts of unexplained vari-

ances e. By modifying the path analytical model the method tries to

infer an optimal solution where a maximum of total variance is ex-

plained. Hence, path analysis tries to do something that is logically impossible, to derive causal relation-

ships from sets of observations.

Path analysis might be a powerful tool. However, it demands very thorough model development and

large data sets. The smaller a data set is the higher is the probability to get a significant global solution together

with significant partial correlations. Path analysis is also not unequivocal. Very often you find more than one

solution that fit well to the data.

Path analysis is largely based on the computation of partial coefficients of correlation. But you have to

know which variables have to be eliminated. This requires thorough prior modelling efforts. Assume the fol-

lowing case with 4 variables. We model the interrelationships between these variables through the following

path diagram. The aim of the path analysis is now to infer the relative strength of correlations between these

variables. This could be done by computing the appropriate partial correlations. Path analysis instead uses stan-

dardized variables instead of raw data. That means all variables are Z-transformed having means of zero and

variances of 1. The fundamental theorem of path analysis tells

now that is is always possible to compute the correlation coeffi-

cients of standardized variables from the total set of simple cor-

relation coefficients. In path analysis these correlation coeffi-

cients of standardized variables are called path coefficients p.

We see that the results of path analysis can’t be better than the

underlying model. Path analysis is a model confirmatory tool.

It should not be used to generate models or even to seek for

models that fit the data set.

How to compute a path analysis? The model above contains four variables that are presumably con-

Y

X3X2 X4X1

e

YX3

X2

X4X1

ee

e

e

e

X Z

Y

WpXW pZX

pZY

pXY

e e

e

e

Page 54: Statistical advices for biologists

54 Statistical advices

nected. We get three regression functions

This is a system of linear equations. We need a set of data for each variable and the equations are then

solved by linear regression. However, we can make things easier. The input values in path analysis are already

Z-transformed variables. Hence

In a first step we multiplied the three equations to get all combinations of Znm. Now remember equation

6.6. The sum of all ZnZm gives rmn, the coefficient of correlation. Summing over all cases gives a relation be-

tween path coefficients and coefficients of correlation. Because a simple sum of all Z-values is zero the error

terms vanish and we have systems of linear equations that can be solved using ordinary matrix algebra. At the

end we get a path diagram as shown in the Fig. above.

Linear path analysis cannot only handle with observ-

able or observed variables. It can also be used to deal with

complex and unobservable, so-called endogen, variables. Look

at the next example. Six exogenous measured variables can be

divided into two groups. X1 to X4 are related and contain a

common source of variance. This variance can be identified

and we define a model with the intern endogen variable Y1. In

the same way define X5 and X6 a variable Y2. Y1 and Y2 ex-

plain a part of the variance of the variable Z. All relationships

can be defined by path coefficients. In this case we use path

analysis for a whole model with measurable and latent

x w

x y

z x z y

W p X eX p Y e

Z p X p Y e

⎫= +⎪

= + ⎬⎪= + + ⎭

x w

x y

z x z y

p X W e 0X p Y e 0

p X p Y Z e 0

− + − =− − =

− − + − =

W x w X

X x y Y

Z z x X z y Y

W Y x w X Y Y

X W x y Y W W

Z W z x X W z y Y W W

X Z x y Y X X

X Y x y Y Y Y

Z Y z x X Y z y Y Y

W Y x w X Y

X W x y Y W

Z W z x X W z y Y W

X Z x y Y X

X Y

Z p Z eZ p Z e

Z p Z p Z e

Z Z p Z Z e ZZ Z p Z Z e Z

Z Z p Z Z p Z Z e Z

Z Z p Z Z e Z

Z Z p Z Z e Z

Z Z p Z Z p Z Z e

r p rr p r

r p r p r

r p r

r p

= +

= +

= + +

↓= += +

= + +

= +

= +

= + +

↓==

= +

=

= x y

Z Y z x X Y z yr p r p= +

X1

X2

X3

X4

X5

X6

Y1

Y2

exogen endogen

Z e

pp

X

W

Z

Y

pXW

pYX

pXZ pYZ

Page 55: Statistical advices for biologists

Statistical advices 55

variables. The latter type of variable can be identified by factor analysis, with which we deal later. To do so we

need linear structure models and this technique is best known under the name LISREL (Linear structure mod-

els).

In the biological sciences this technique is seldom used, mainly due to the many difficulties in interpret-

ing the results. It needs even more thorough a priori modelling effort. In biology the number of variables is in

most cases rather limited (less than 10). For n = 10 we need 10*(10-1)/2 = 45 correlation coefficients. For esti-

mating these at low error levels we need at least 10 independent observations for each variable pair. In praxis

for even moderate large models hundreds of data sets are necessary. Therefore biologists more often rely on

multiple regression in combination with factor analysis than on LISREL. In Statistica the SEPATH module is a

powerful tool for developing structured models.

Page 56: Statistical advices for biologists

56 Statistical advices

6.4 Logistic regression

At the end of this lecture we have to deal with still another form of regression. Bivariate or multiple

regression needs continuous variables to be run. But

often our data are of a discrete type or we have mixed

data. Is it possible to run a regression with such data

types? Look at the next Figure 6.4.1. Four species of

closely related plants were studied at five stands (the

colored bars) and their aboveground biomasses com-

pared. An analysis of variance resulted in a highly sig-

nificant difference (F = 58, p(F) < 0.001). But we can

also try a simple linear regression between species (coded from 1 to 4) and biomass. We get a sufficiently good

regression. But this regression model would not be able to predict a species from its body weight. A body

weight of 2.5 would point either to species B or C. We might try to solve the above regression equation for x

and get x = (2.0 + 1.05) / 1.42 = 2.5. This is exactly between 2 and 3. From the regression we are not able to

decide unequivocally whether certain biomasses point to one or another species.

But we can solve our problem. This statistical solution is the so-called logistic or logit regression. The

logic behind this type of regression is very simple and best explained

by the next example. In archaeological research it is sometimes diffi-

culty to separate the sexes from cranial or postcranial skeleton rudi-

ments because for most traits sexes highly overlap. Assume, for in-

stance, that we have a series of skeleton fragments and want to infer

the sex. To do this we first have to have a model. We generate such a

model from a series of skeleton samples with known sex and per-

form a multiple regression. But our dependent variable, the sex, has

only two values, male and female. Multiple regression, however,

assumes the dependent variable to be continuous. We have to trans-

form it and we do this via the already known logistic function. The

logistic function has the form

(6.4.1)

Our multiple regression has the general form

To derive an appropriate model we start with odds, that

means the quotient of the probabilities O = p/(1-p). Odds

have values from 0 to ∞. ln(O) in turn goes from -∞ to ∞.

Now we use a simple multiple regression to estimate ln

(O) from or predictors. Hence

11 1

y

y y

eZe e−= =

+ +

01

n

i ii

Y a a x=

= + ∑

y = 1.42x - 1.05R2 = 0.93; p < 0.01

01234567

A B C D

Species

Abov

egro

und

biom

ass

A B CMale 5.998 0.838 2.253Male 3.916 0.992 1.964Male 4.511 0.904 1.930Male 5.940 0.795 1.171Male 6.532 0.574 1.390Male 6.513 1.036 0.571Male 3.052 0.584 2.179Male 3.512 1.126 1.843Male 6.676 0.992 2.288Male 6.976 0.502 1.062

Female 5.649 0.913 2.231Female 5.712 0.474 2.237Female 5.112 0.277 1.009Female 3.681 0.329 2.420Female 5.239 0.922 1.592Female 5.180 0.546 2.418Female 2.133 0.300 3.087Female 5.361 0.472 2.175Female 6.460 0.321 1.007Female 6.839 0.426 3.179

Fig. 6.4.1

0

0.2

0.4

0.6

0.8

1

1.2

0 5 10 15 20Y

Z

Threshold

Indecisive region

Surely males Surely females

Fig. 6.4.2

Page 57: Statistical advices for biologists

Statistical advices 57

We got the general logistic regression equation where logit stands for log odds.

(6.4.2)

This is a logit regression. The Figure 6.4.2 shows how the logit regression transforms the y value into a

range between 0 and 1. We see a threshold where an unequivocal decision is not possible but for most regres-

sion values we should be able to decide whether a given set of morphological traits stems from a male or a fe-

male skeleton. The next table shows values of morphological traits together with the sex of the person from

whom these values were measured. Statistica computes

for this the following regression function

The result is shown in Fig 6.4.3. Of 20 samples 14

allow an unequivocal decision to be make. In five cases a

clear decision is impossible and there is one obviously

wrong result. From this we conclude that the power of our

regression model is about 95%. If we now have a set of

samples from a skeleton of unknown sex, we might use

our regression model to establish the sex. The probability

that we choose the right sex is about 85% (17 / 20).

The logit transformation transforms the data into

the range between 0 and 1. This is the same range a probability can take. We might therefore interpret the result

of a logit regression as a probability that a certain set of data belongs to one of both types of Y.

Fig. 6.4.4 shows a comparison of our logit result with an ordinary multiple regression. We see that the

multiple regression to a certain extent also finds out males and females. But the result is much less decisive

than before. There are only seven unequivocal decisions, four results are erroneous. We also see that the errors

in both models differs.

nn 0 i i

i 10 i ii 1

n

0 i ii 1

a a xn a a x

0 i ia a xi 1

p p eln a a x e p1 p 1 p

1 e

==

=

++

+=

∑∑⎛ ⎞

= + → = → =⎜ ⎟− −⎝ ⎠ ∑+

01

011

=

=

+

+

∑=

∑+

n

i ii

n

i ii

a a x

a a x

eZ

e

0.19 0.2 6.36 1.77

0.19 0.2 6.36 1.771

A B C

A B C

eZe

− + − +

− + − +=+ 0

0.20.40.60.8

1

Mal

e

Mal

e

Mal

e

Mal

e

Mal

e

Fem

ale

Fem

ale

Fem

ale

Fem

ale

Fem

ale

Sex

Z

00.20.40.60.8

1

Mal

e

Mal

e

Mal

e

Mal

e

Mal

e

Fem

ale

Fem

ale

Fem

ale

Fem

ale

Fem

ale

Sex

Z

Fig. 6.4.3

Fig. 6.4.4

Page 58: Statistical advices for biologists

58 Statistical advices

6.5 Assessing the goodness of fit

Look at the following plot. Our problem is to fit a model to a set of 15 observations. The question is

what model fits best. Spreadsheet programs offer some simple build in functions (a power, a logarithmic, an

exponential, and linear and higher order algebraic functions (up to the 5th order). Often we need other models

and then we have to use the non-linear regression modules of statistic packages. They use least square algo-

rithms to fit self-defined models. However, how to assess what model fits best? Of course we might use the

fraction of explained variance, the coefficient of determination R2. In the example of Fig. 6.5.1 we get: linear

R2 = 0.71; quadratic R2 = 0.83; power function R2 = 0.82.Which model fits best? We can’t decide. Judged only

by the R2 values the quadratic might look best. In fact, the data points were generated by a linear model that

fitted worst. This is an often met problem and in fact there is no general solution to the problem of finding the

best model. R2 is not a very sensitive measure of goodness of fit because it is easy to get high values with dif-

ferent models. If possible we have to enlarge the number of data points.

Even worse is the situation if we have to

compare multivariate models. For instance we have

to compare results of multiple regressions that con-

tain different numbers of predictor variables. Of

course the higher the number of predictors the

higher will be the variance explained. Thus, the

problem is to find the optimum number of predic-

tors. One criterion in multiple regression is that we

should eliminate all variables that do not signifi-

cantly contribute to the overall R2 value. In our

case we can only leave the quadratic or the linear term in the quadratic model. To decide how many parame-

ters to leave we can use the so-called Akaike information criterion (AIC). It gives the amount of information

explained by a given model and is defined as

(6.5.1)

where L is the maximum likelihood estimator of goodness of fit and K the number of free parameters of the

model. In the example above the linear and the power function models have two free parameters. The quadratic

model has three free parameters. L can be any appropriate measure of fit. Often R2 is used. K is often identical

with the number of free variables (predicators) of the model. The lower AIC is, the better fits a given model to

the data. For comparison of two models we can take the difference |AIC1 - AIC2|. This difference is normally

distributed and we assume therefore that differences are significant at p < 0.05 if ΔAIC is larger than 1.96. For

the example above we get ΔAIC (quadratic - power) = 1.96. ΔAIC (linear - power) = 0.27. Therefore we inter-

pret that the power function with only two free parameters fits not significantly better than the linear model.

Another important criterion is the Bayesian information criterion (BIC) (sometimes termed Schwarz

criterion )

(6.5.2)

where N is the number of data points. This models points in our case unequivocally against the quadratic func-

2 ln( ) 2= − +AIC L K

ln( ) ln( )= +SC N L K N

0

0.2

0.4

0.6

0.8

1

1.2

1.4

0 0.2 0.4 0.6 0.8 1

X

Y

Fig. 6.5.1

Page 59: Statistical advices for biologists

Statistical advices 59

tion. ΔBIC (quadratic - power) = 2.96. ΔBIC (linear - power) = 0.27.

An important point is that AIC or BIC must not be used in parallel with R2 as the measure of goodness

of fit. Both methods rely on different philosophies. For instance in multiple regression variable reduction via

AIC and via R2 will result in different final models. R2 of the AIC model is now not longer a measure of ex-

plained variance.

For detailed information about these two criteria and other less often used see http://

www.aps.uoguelph.ca/~lrs/ANSC637/LRS16/.

Page 60: Statistical advices for biologists

60 Statistical advices

7. Analysis of variance

Consider an experiment designed to infer the influence if light in-

tensity on plant growth. Four experimental plots (A to D) are installed

each with five replicates. The four plots differ in total light energy supply.

After the experiment we measure total plant biomass in each of the 25

experimental plots. The raw data are given in the Table beside. The ques-

tion is now: does light intensity influence total biomass? Of course we

could take our t-test and compare all five plants separately (giving 10 sin-

gle comparisons). But it is possible that none of the pairwise comparisons

gives a significant result although the treatments differ due to a trend in the

data set. It would be better to treat all groups simultaneously. This is the

aim of an analysis of variance. The idea behind the ANOVA is very sim-

ple. It was developed by the biostatistician and genetic Sir Ronald Fisher

(1890-1962) especially for the biological sciences.

The total variance of the whole data set is given by

k denotes the number of groups (treatments). N is the total number of data points (the sample size) and ni

denote the numbers of data points within each treatment. For simplicity the ANOVA uses sums of squares SS

= s2 * (n-1). Hence

(7.1)

Now we divide the total variance of all 25 plots into two groups. One

group contains the variance within the 4 groups, the second group the vari-

ance between the groups (computed from the grand mean). Under the as-

sumption that the within group variability is caused by the same set of

unknown variables (that operate within the groups in a similar way) any

difference in the between group variability should be caused by the treat-

ment. In a next step we compare both variances. We know already a way

to compare variances. It is the F-test of Fisher.

(7.2)

How to calculate within and between group variances? We compute

22,

1 12 1

( )( )

1 1

inkN

i jki jk

total

x xx xs

N N= ==

−−= =

− −

∑∑∑

2,

1 1( )

ink

total i j totali j

SS x x= =

⎛ ⎞= −⎜ ⎟⎜ ⎟

⎝ ⎠∑ ∑

2

2between

within

F σσ

=

Plot Light intensity Biomass1 A 102 A 123 A 154 A 95 A 76 B 137 B 168 B 129 B 1410 B 1711 C 1312 C 1813 C 1714 C 1115 C 1516 D 517 D 918 D 819 D 720 D 1021 E 522 E 623 E 724 E 225 E 4

7D256D245D233D227D215D209D199C186C1711C164C1510C1415C135B129B115B108B93B86B74B69A59A47A311A210A1

BiomassLightPlot

7D256D245D233D227D215D209D199C186C1711C164C1510C1415C135B129B115B108B93B86B74B69A59A47A311A210A1

BiomassLightPlot

}σ2

}σ2

}σ2

}σ2

}σ2

μA

μB

μC

μD

Page 61: Statistical advices for biologists

Statistical advices 61

(7.3)

We sum over the k groups. Why multiplying with ni, the number of data points in each treatment? To compute

the between variance we assume that the total variance comes solely from the differences between the treat-

ments. Hence, we replace the within values through the within mean. The new total sum of squares is then

according to eq. 7.3

Now we need the degrees of freedom. If we would in our example divide SSbetween through the group

number (4) we would underestimate the total variance. Why? Because if we have means of three groups, the

variance computed by including the fourth group is no longer a random variable. It is already determined by the

other three values. We have to divide through 3, the number of variables that can fluctuate at random. In other

words, we have to divide through the number of degrees of freedom. This is for the between group variance

dfbetween = k - 1 if k denotes the number of groups.

The within group variance is given by

(7.4)

SSwithin is therefore the sum of the variances computed within the groups. This is the part of variance not

influenced by the treatment. It is introduced by other (often unknown or not measured) factors and is often also

called SSerror. If SSwithin would equal SSbetween the treatment would not influence the dependent variable. Other-

wise SSbetween would introduce an additional part of variance. Variances of independent random variates are

additive. We get a fundamental equation on which the analysis of variance is based.

(7.5)

For the degrees of freedom a similar equation holds. We have dfwithin = N-k degrees of freedom. Hence.

(7.6)

In our case equation 7.6 gives (25-1) = (4-1) + (25-4). This is immediately clear. If we would compute

the total variance (computed from all cases) directly we would have to divide through n-1 = 24. SStotal has 24

degrees of freedom.

Our F-test looks therefore as follows

(7.7)

2

1( )

k

between i i totali

SS n x x=

= −∑

2 2

1( ) ( )

in

i i total i i totalj

SS x x n x x=

= − = −∑

2,

1 1( )

ink

w ith in i j ii j

SS x x= =

⎛ ⎞= −⎜ ⎟

⎝ ⎠∑ ∑

total between withinSS SS SS= +

total between withindf df df= +

11

between

between

within within

SSSSN kkF SS k SS

N k

−−= =−

Variable df MS df MSEffect Effect Error Error F p(F)

Light intensity 4 91.86 20 5.84 15.72945 5.72E-06

Page 62: Statistical advices for biologists

62 Statistical advices

Statstic programs give

now the following output (in

this case it would even be

faster to compute F by hand).

The variable light intensity

has 4 degrees of freedom.

Statistica denotes MS (mean

sums of squares) instead of

SS. MS = SS / dF. MS effect

is the between group variabil-

ity, MS error the within group

variability. F is the quotient of

MSeffect / MSerror = 15.7. The corresponding probability level is far below 1%. In other words, we conclude that

light intensity has a statistically significant effect on plant growth.

A numerical example how to compute an ANOVA is shown in the next table. A standard matrix con-

tained data from 4 treatments with 5 observations. Each gave four group means. Do these group means differ?

SSbetween and SSwithin are computed separately and compared with SStotal. You see that the sum of SSbetween and

SSwithin is indeed identical to SStotal.

The ANOVA can easily be extended to deal with more than one influencing variable. With the same

reasoning as above we can divide the total variance into parts where each part represents the fraction of vari-

7.1 Advices for using ANOVA: • You need a specific hypothesis about your variables. In particular, designs with more than one

predicator level (multifactorial designs) have to be stated clearly.

• ANOVA is a hypothesis testing method. Pattern seeking will in many cases lead to erroneous

results.

• Predicator variables should really measure different things, they should not correlate too high

with each other

• The general assumptions of the GLM should be fulfilled. In particular predicators should be ad-

ditive. The distribution of errors should be normal.

• As in multiple regression it is often better to use log-transformed values

• In monofactorial designs where only one predicator variable is tested it is often preferable to use

the non-parametric alternative to ANOVA, the Kruskal Wallis test. This test does not rely on

the GLM assumptions but is nearly as powerful as the classical ANOVA.

• A non-parametric alternative for multifactorial designs is to use ranked dependent variables.

You loose information but become less dependent on the GLM assumptions.

• ANOVA as the simplest multivariate technique is quite robust against violations of its assump-

tions.

Observations A B C D1 0.08 0.19 0.83 2.80 0.404 0.109 0.220 2.0592 0.71 1.21 0.71 2.69 0.404 0.109 0.220 2.0593 0.19 1.97 1.10 1.93 0.404 0.109 0.220 2.0594 0.51 0.19 0.11 2.57 0.404 0.109 0.220 2.0595 0.73 0.19 0.30 2.58 0.404 0.109 0.220 2.059Group mean 0.445 0.750 0.611 2.515

0.131 0.319 0.046 0.0810.070 0.216 0.010 0.0320.065 1.484 0.244 0.3420.004 0.314 0.250 0.0040.082 0.312 0.096 0.004

Total SSwithin 4.11Total SSbetween 13.96Grand mean 1.08

1.00 0.80 0.06 2.960.14 0.02 0.14 2.610.79 0.79 0.00 0.720.32 0.79 0.94 2.230.12 0.79 0.61 2.24

Grand SS 18.07SSbetween+SSwithin 18.07

F 18.14F-test 2.118E-05

Treatments

SSwithin

Grand SS

SSbetween

Page 63: Statistical advices for biologists

Statistical advices 63

ance caused by a certain variable. The next Table gives our plant

data with an additional variable, nutrient availability, included.

Now, we have a two-factorial design. We compute the total sums

of squares and the sums of squares between light intensity and be-

tween nutrient availability. This is already quite time consuming to

do it by hand. But our statistic package gives immediately the fol-

lowing output.

We have MS effect light intensity, nutrients and the com-

bined effect of light and nutrients. Again, we have the within vari-

ance MS error, which is the same for all three combinations of ef-

fects. The quotients of MSeffect and MSerror is again our F-value. We

see that only light has a significant effect. Nutrient availability and

the combined effect of light and nutrient do not significantly con-

tribute to total variance. Of course, we have always to take care

that sums of squares can be computed. So, for each combination of

variables at least two data points must be available. Otherwise our experimental design would be incomplete.

What else has to be remembered? To answer this question we have to deal with the relationships be-

tween the variables in more detail. We saw already that variances of a set of variables can be combined in a

linear manner

(7.8)

If we now define one of the variables Y as an dependent variable we would be able to express the vari-

ance of Y from the variances of the other independent variables

(7.9)

In other words, the variance of the dependent variable can be expressed by the sums of variances and

covariances of the independent variables and a term that contains the variances introduced or co-introduced by

Y. This is our within group variability. The aim of an ANOVA is therefore to compute these variance from the

data set and to compute all respective quotients σi2 / σError

2 and covi / σError2.

Additionally, we know already that if we can write the variances in such an additive form, we have the

same relation for the means.

(7.10)

The last two equations are fundamental and form the basis of most multivariate tests that rely on

2 2,covtotal i i jσ σ= +∑ ∑

2 2 2 2 2, , ,cov ( cov ) covY i Y i j Y total i Y i Y i j Y Errorσ σ σ σ σ≠ ≠ ≠ ≠= + + − = + +∑ ∑ ∑ ∑ ∑

Y i Errorμ μ μ= +∑

Plot Light intensity Nutrient Biomass1 A High 102 A High 123 A Low 154 A Low 95 A Low 76 B High 137 B High 168 B Low 129 B Low 14

10 B Low 1711 C High 1312 C High 1813 C Low 1714 C Low 1115 C Low 1516 D High 517 D High 918 D Low 819 D Low 720 D Low 1021 E High 522 E High 623 E Low 724 E Low 225 E Low 4

df MS df MSVariables Effect Effect Error Error F p(F)Light intensity 4 88.89 15 7.388889 12.03023 0.00014Nutrients 1 0.806667 15 7.388889 0.109173 0.745658Light - Nutrients 4 1.29 15 7.388889 0.174586 0.948023

Page 64: Statistical advices for biologists

64 Statistical advices

the general linear model.

An ANOVA can be used as an alternative to the t-test! Assume you have only two groups A and B.

Then the F-test is identical to a t-test for independent variables. Some researchers prefer the F-test over the

t-test for pairwise comparisons.

ANOVA and multiple regression are very similar. Both rely on the GLM and computations of variances

and covariances. It takes therefore no wonder that necessary or optimal samples sizes are also similar. As in the

case of multiple regression you have to distinguish between test and experiment wise error rates and you

should use Bonferroni corrections.

In the previous case we dealt with only one independent variable (or predictor variable), the light in-

tensity, plant biomass was the dependent variable. The ANOVA can easily be extended to deal with more than

ONE predictor variable. In this case we speak of multifactorial designs. With the same reasoning as above we

can divide the total variance into parts where each part represents the fraction of variance introduced by a cer-

tain variable. The next Table gives our plant data with an additional variable, nutrient availability. Now, we

have a two factorial design. Equation 7.5 modifies to

(7.11)

The degrees of freedom come from

(7.12)

where k and m are the numbers of Categories In A and B and n is the number of cases.

We have the variance part introduced by the factor light (SSA) only, by the additional factor nutrients

(SSB) only, by the combined effect of light and nutrients (SSAxB), and of course by the within variance (SSerror).

SSA is computed separately for both groups of nutrients to exclude the influence of nutrients. SSB is computed

separately for the four groups of nutrients to exclude the influence of light intensity. Additionally we need the

SSAxB. Under the hypothesis that light and nutrients are not independent the combined action of both variables

might influence the plant biomass.

Be careful. For every treatment of light intensity you have

to have at least two treatment cases of nutrients. Otherwise it

would be impossible to compute the within variability of nutrients

inside the treatment light. However in reality two cases are much

too less. Even for an approximated estimate of the within variance

you need at least 6 treatments for each combination of light and

nutrients. Hence, you need at least 4*2*6 = 48 cases. The number

of experimental data necessary for multifactorial designs raises

very fast.

We computed the total sums of squares and the sums of

squares between light intensity and between nutrient availability.

This is already quite time consuming to do it by hand. But our

statistic package gives immediately the output shown above. The

Statistica output shows separate results for the variables

= + + +total A B AxB errorSS SS SS SS SS

( 1) ( 1) ( 1)( 1) ( 1)= + + +

= − + − + − − + −total A B AxB errordf df df df df

kmn k m k m km n

Plot Light intensity Nutrients Biomass1 A A 102 A A 113 A A 74 A B 95 A B 96 B A 47 B A 68 B A 39 B A 810 B B 511 B B 912 B B 513 C A 1514 C A 1015 C A 416 C B 1117 C B 618 C B 919 D A 920 D A 521 D A 722 D A 323 D B 524 D B 625 D B 7

Page 65: Statistical advices for biologists

Statistical advices 65

(treatments) light (effect 1) and nutrients (effects 2). These are called the main effects. Additionally the com-

bined effect of light and nutrients is given, the secondary or combined effects. Again, we have the within vari-

ance MS error, which is the same for all three combinations of effects. The latter are computed over all groups

of combinations of the main effects. The quotients of MSeffect (MSbetween) and MSerror (MSwthin) is again our F-

value. For light I used the same data as in the monofactorial design. We see that including a new treatment

variable changed the significance levels for light too. Now light appears to be less significant.

Nutrient availability and the combined effect of light and nutrient do not significantly contribute to total

variance. Of course, we have always to take care that sums of squares can be computed. So, for each combina-

tion of variables at least two data points must be available. Otherwise our experimental design would be incom-

plete. The table beside shows such a typical incomplete design. We have one metrically scaled independent

variable and three predictors. However, a full ANOVA including all three predictors is impossible to compute

Dep Pred A Pred B Pred C0.166325 A 1 H0.259949 A 1 H0.594445 A 1 H0.425759 A 1 H0.09268 B 1 H

0.005181 B 1 H0.41623 B 2 H

0.111211 B 2 H0.960788 B 2 H0.819748 C 2 H0.649385 C 2 H0.937118 C 2 H0.219705 C 2 H0.378985 C 2 I0.266792 C 2 I0.34661 D 2 I

0.358633 D 2 I0.767452 D 2 I0.894365 E 2 I0.202289 E 2 I0.230526 E 2 I0.722637 E 2 I0.438195 E 2 I0.561168 E 2 I0.785699 E 2 I

Page 66: Statistical advices for biologists

66 Statistical advices

because not all predicator combinations occur. We will deal with incomplete designs in chapter 14..

Now comes one example of the category how to lie with statistics. The next Statistica table contains the

result of an ANOVA with three effects (VAR2, VAR3, and VAR4). We see that VAR2 and the combined ef-

fect of all predictors are statistically significant at the 5% error level. However, as independent variables I used

simple random numbers. There shouldn’t be any significant results. The probability for a significant result

should be 1 out of 20 = 5%). What has happened? We used an error level α of 5% for the whole ANOVA re-

sult. The probability to make no error is 1 - α. The probability to make no error in n experiments is therefore

(1 - α)n. What is then the probability that in n experiments we reject erroneous H0, that is that we make a type II

error? This probability is β = 1 - (1 - α)n. In our above example we have 3 independent variables and their com-

binations. Our probability level is therefore not α = 0.05. It should be between β = 1 - (1 - α)3 = 0.14 and β =

1 - (1 - α)7 = 0.30. Hence for single contrasts we get a new error level of 14 to 30% and we expect to make an

erroneous decision in 1 out of 6 to 1 out of 3 cases. Our level of α = 0.05 is the test wise error rate. But if we

use a test several times with the same set of data or compute a multivariate test with many variables simultane-

ously we have to deal with the experiment wise error rate. Again we have to correct our initial significance

level by the following equation

(7.13)

The Bonferroni correction reduces the test wise error level to reach in an acceptable experiment wise

error level. You divide your initial error level through the number of independent variables, or, if you want to

be on the sure side, through the number of combinations of these variables. In our above case we should there-

fore only accept significance levels p(F) below 0.05 / 7 = 0.007 for single comparisons to reach in an experi-

ment wise error level of 5%.

What is the necessary sample size for the within sums of squares SSerror? In other words what is the

equivalent of a power analysis in the case of an ANOVA. We can compute this by a similar t-test model as

above. We define the effect size by the maximum difference of means of the groups. We get

(7.14)

Hence

(7.15)

where k is the number of groups and N is the total sample size (the total number of observations). Again,

we need information about the within group variability.

Now will deal with two non-parametric alternatives to the ANOVA. Assume we have an observational

series with a single discrete independent variable, a monofactorial design. Then, we can use the so-called

Kruskal-Wallis test or Kruskal-Wallis ANOVA by ranks. In principle, the Kruskal-Wallis is computed in

the same way as the U-test. We compute the total rank sums as the base for a test statistic. Our test statistic is

1/* 1 (1 )= − − ≈n

nαα α

within

effect size2

≈Ntk σ

2

2ffect size

⎛ ⎞= ⎜ ⎟⎝ ⎠

withintN ke

σ

Page 67: Statistical advices for biologists

Statistical advices 67

(7.16)

where N is the total number of observations, ni the number of observations of group i, and k the number of

groups. The Table shows an example how to compute a Kruskal-Wallis test with Excel. We have a series of 53

observations divided into 4 groups or treatments. The KW-value of 9.15 has again to be compared with tabu-

lated ones. For values of r > 5 or larger sample sizes KW is approximately χ2 distributed and values can be

taken from a χ2 table with r-1 degrees of freedom. In our case this value for 3 degrees of freedom and α = 0.95

is χ2 = 7.81. Our value of 9.15 is larger than 7.81 and we accept the hypothesis that there is a difference be-

tween the treatments at an error level of 5% (the exact error level given by Statistica is 2.73%). The Kruskal-

Wallis test has in monofactorial designs nearly the same power as an ordinary ANOVA and should be used in

all cases where we are not sure about the underlying frequency distributions of the populations.

A second alternative is to use a rank order ANOVA. In this case we apply an ordinary ANOVA but use

for the dependent metrically scaled variable ranked data. Such a rank ANOVA is applicable in monofactorial

and multifactorial designs. An example is shown in the next table. We have 29 data sets grouped into four ef-

fects. Now we rank these data from the largest (0.929 = rank 1) to the smallest (0.082 = rank 29) using the Ex-

2

1

12 3( 1)( 1)

ri

i i

RKW NN N n=

= − ++ ∑

A B C D E F G H I1 Group 1 Group 2 Group 3 Group 1 Ranks of group 1 Ranks of group 1 Ranks of group 3 Ranks of group 4 Sums2 0.01 3.92 5.93 1.97 1 29 37 203 0.60 0.38 0.64 5.17 8 4 9 354 1.18 6.58 7.25 1.56 12 41 44 165 1.60 7.75 1.80 0.87 17 46 18 106 0.51 9.40 0.08 0.48 6 50 2 57 2.75 0.57 11.96 7.78 22 7 53 478 4.02 3.33 3.65 2.76 31 25 28 239 1.81 9.03 5.01 6.64 19 49 34 42

10 3.13 2.62 7.31 3.40 24 21 45 2611 3.59 6.35 4.04 6.36 27 39 32 4012 1.51 1.26 5.82 0.18 15 13 36 313 1.34 6.82 9.80 5.97 14 43 51 3814 0.92 8.62 10.93 11 48 5215 4.90 3316 4.01 30

17=+POZYCJA(A2;$

A$2:$D$16;1)=+POZYCJA(B2;$

A$2:$D$16;1)=+POZYCJA(C2;$

A$2:$D$16;1)=+POZYCJA(D2;$

A$2:$D$16;1)18 R 270 415 441 305 40820.23718

19 =SUMA(E2:E16) =SUMA(F2:F16) =SUMA(G2:G16) =SUMA(H2:H16) =E19/15+ F19/13+G19/13+

20 KW 9.154034296

21 =12/(53*54)*I18-

3*54

Page 68: Statistical advices for biologists

68 Statistical advices

cel build in function pozycja(..). We compare the results of ordinary ANOVA,

ANOVA with ranked data and the KW-test. The ANOVA gives a probability

level for H0 of p(F) = 0.007, the ANOVA with ranked data proposes p(F) =

0.014, and the Kruskal Wallis test returns p = 0.024. All three tests point to significant differences between the

four groups. The non-parametric alternative returns a higher significance level. This is caused by the loss of

information due to the ranking of the data. But the

probability to make a type I error (to accept the

wrong hypothesis) is also reduced.

A simple ANOVA is easy to compute. How-

ever, variance analytical techniques can be greatly

extended. A first extension regards the inclusion of

metric and categorical variables. In this case we

perform a covariance analysis (ANCOVA). In an

ANCOVA we use the residuals of a multiple re-

gression of a dependent variable on independent

metrically scaled variables (the covariates) as the

test variable in a ordinary ANOVA. This is shown

in the next plant example. We studied plant growth

on different soils in dependence on light intensity

(low/high). A simple ANOVA pointed indeed to

Light as a factor that influenced plant growth. We

further assume that growth is also dependent on the

amount of nutrients in the soil. Fig. 7.1 shows in-

deed a general regression of growth on nutrients

Dep Ranks Effect0.488964 13 A0.366997 17 A0.253452 22 A0.777929 11 A0.321003 19 A0.126373 24 A0.111894 26 A0.055178 27 A0.982267 8 B0.946089 9 B1.763621 3 B0.361607 18 B1.620806 5 B1.854719 2 B1.206337 7 B0.627104 12 C0.236488 23 C0.380474 15 C0.311656 20 C0.370961 16 C0.404568 14 C0.042592 29 C0.12325 25 D

0.256909 21 D1.535243 6 D2.754496 1 D0.945028 10 D0.048601 28 D1.63511 4 D

Growth Light Nutrients Different regressions

Single regression

Residuals different

regressions

Residuals single

regression0.52 high 0.83 0.83 0.29 -0.31 0.231.38 high 1.80 0.94 1.00 0.44 0.380.85 high 1.87 0.94 1.05 -0.09 -0.200.00 high 2.21 0.98 1.29 -0.98 -1.291.63 high 2.37 1.00 1.41 0.63 0.212.20 high 2.43 1.00 1.46 1.19 0.740.87 high 2.55 1.02 1.55 -0.15 -0.680.74 high 2.66 1.03 1.62 -0.29 -0.890.65 high 3.26 1.10 2.06 -0.44 -1.414.05 medium 3.27 3.73 2.07 0.31 1.983.12 medium 3.49 3.88 2.23 -0.76 0.893.97 medium 4.28 4.42 2.80 -0.44 1.176.55 medium 4.80 4.77 3.18 1.79 3.372.72 medium 5.13 4.99 3.42 -2.28 -0.715.07 medium 5.25 5.08 3.51 -0.01 1.557.52 medium 5.78 5.43 3.90 2.09 3.635.94 medium 6.43 5.88 4.37 0.06 1.577.94 medium 6.47 5.90 4.40 2.04 3.543.30 medium 6.78 6.11 4.62 -2.81 -1.328.99 low 7.41 9.15 5.09 -0.16 3.9010.34 low 8.00 8.41 5.52 1.93 4.836.28 low 8.67 7.57 6.00 -1.29 0.284.93 low 8.76 7.45 6.07 -2.53 -1.146.54 low 9.16 6.95 6.36 -0.41 0.188.48 low 9.19 6.92 6.38 1.57 2.106.79 low 9.79 6.16 6.82 0.62 -0.036.91 low 9.84 6.10 6.85 0.81 0.063.91 low 10.48 5.29 7.33 -1.38 -3.426.02 low 10.56 5.19 7.38 0.83 -1.37

Page 69: Statistical advices for biologists

Statistical advices 69

(in black). However for each light intensity class

there is a different regression (the colored lines).

Now we calculate the residuals of the single regres-

sion and the different regressions of each treat-

ment. However using the different regressions of

each treatment to calculate the residuals would

include the effect of the treatment through the

backdoor. Indeed the respective ANOVA gives F =

0 in the Statistica example.

The ANCOVA with nutrients as covariate now tells that light has only a marginal influence on growth

after correcting for the effect of nutrients. Using the residuals of the grand regression between nutrients and

growth as the dependent variable in a simple ANOVA gives nearly the same result. The different significance

levels result from the different degrees of freedom. The simple ANOVA

doesn not know anything about the variable nutrient and dferror = 27. In the

ANCOVA one df goes to nutrients and dferror = 26.

The next example shows a bifactorial ANCOVA of the same plant example.

After regressing growth against nutrients light intensity remains a significant

predictor of plant growth. If we first regress growth on nutrients and use the

residuals (ZMN4 in the Statistica example) in a simple ANOVA we get

nearly the same result. Again the different significance levels stem from the

different degrees of freedom. Covariance analysis has the same limitations

and prerequisites than multiple regression and ANOVA. Both rely on GLM.

The covariates have to be metrically scaled.

Another special case of ANOVA regards repetitive designs. For instance in

medical research we test patients before and after medical treatment to infer

y = 0.1094x + 0.7388

y = 0.677x + 1.5206

y = -1.2557x + 18.453

y = 0.7286x + 0.3128

0.00

2.00

4.00

6.00

8.00

10.00

12.00

0.00 5.00 10.00 15.00

Nutrients

Gro

wth

Fig. 7.1

Growth Light CO2 Nutrients0.13 high high 3.830.26 high high 4.660.35 high high 5.920.25 high high 2.670.27 high high 1.470.30 high high 3.180.82 high high 5.710.19 high low 4.200.24 high low 5.340.50 high low 7.200.31 high low 8.640.84 high low 8.490.54 high low 4.130.49 high low 0.580.06 low high 6.440.57 low high 7.260.72 low high 9.770.00 low high 5.140.51 low high 1.170.86 low high 9.081.46 low high 4.270.90 low low 0.770.42 low low 7.171.40 low low 3.310.54 low low 7.520.24 low low 0.500.91 low low 9.220.98 low low 8.071.08 low low 6.60

Page 70: Statistical advices for biologists

70 Statistical advices

the influence of the therapy. In this case we have to divide the total variance (SStotal) in a part that contains the

variance between patients (SSbetween) and within the patient (SSwithin). The latter can be divided in a part that

comes from the treatment (SStreat) and the error (SSerror) (Fig. 7.2). Hence we have one variance more to con-

sider, the a priori differences between the patients that are not influenced by the medical treatment. Assuming a

monofactorial design we calculate the necessary sums of squares from

(7.17)

where xij is the measurement of patient i within treatment j, is the grand mean, is the mean of

the k treatments , and the mean of the n patients. SStotal is of course the sum of these sums of squares.

The degrees of freedom come from

To test for significance we apply again the F test with (k-1) and (n-1)(k-1) degrees of freedom

k n2

total ijj 1 i 1

n2

betwen ii 1

k n2

within ij ij 1 i 1

k2

treat ij 1

k n2

error ij i jj 1 i 1

SS (x x)

SS k (P x)

SS (x P )

SS n (T x)

SS (x P T x)

= =

=

= =

=

= =

= −

= −

= −

= −

= − − +

∑ ∑

∑ ∑

∑ ∑

x T

P

total between within between treat errorSS SS SS SS SS SS= + = + +

total between within between treat errordf df df df df dfkn 1 n 1 n(k 1) n 1 k 1 (n 1)(k 1)

= + = + +

− = − + − = − + − + − −

SStotal

SSbetween SSwithin

SSErrorSStreat

Fig. 7.2

Page 71: Statistical advices for biologists

Statistical advices 71

(7.18)

The Excel example at the next page shows how to calculate a repeated measures ANOVA The blood

pressure of ten test persons were measured in the morning, in the afternoon, and in the night. The question is

whether blood pressures depends on the time of day. We first calculate SSwithin from the person means and the

grand mean. Next we calculate SSwithin from the single measurements and the person means. SStreat comes from

the mean of the three day times and the grand mean. Lastly, SSerror comes from the measurement and all three

means. We see that indeed SStotal = SSwithin + SSbetween and SSwithin = SStreat + SSerror.

A special technique for repetitive designs is the use of so-called “ipsative” data. Instead of using raw

data the data are transformed by subtracting the case (person) means. Hence SStotal and SSbetween become zero.

Therefore eq. 7.5 reduces to

(7.19)

Used in this way makes the repeated measure ANOVA very easy to calculate even with Ecxel. The sig-

nificance test reduces to

(7.20)

Of course, the above ANOVA scheme can be extended to many treatment variables.

The validity of the F test for the previous ANOVA depends on a series of prerequisites. Particularly the

within variances have to be similar (homogeneous). Further, in repeated designs treatments are often correlated.

In the tables above morning might correlate with evening and night because the test persons react in the same

way on the time of day. These correlations have to be similar for all combinations of treatment. Otherwise the

treatment would be inhomogeneous. Inhomogeneities result often in inflated type I error probabilities. To cor-

rect for this possibility we might correct the degrees of freedom to obtain lower F-values and significance

levels. In eq. 7.18 we have (k-1) degrees of freedom for the effect and (n-1)(k1) degrees of freedom for the

error. To correct for violations of the AOVA prerequisites we multiply these degrees of freedom by a factor ε.

At maximum heterogeneity

k2

jj 1treat error

k n2error treat

ij i jj 1 i 1

n (T x)SS df (n 1)(k 1)FSS df k 1(x P T x)

=

= =

−− −

= =−− − +

∑ ∑

total betwen

k n2

within ijj 1 i 1

k 2

treat ij 1

k n2

error ij jj 1 i 1

SS SS 0

SS x

SS n T

SS (x T )

= =

=

= =

= =

=

=

= −

∑ ∑

∑ ∑

k 2

jj 1treat error

k n2error treat

ij jj 1 i 1

n(n 1) TSS dfFSS df (x T )

=

= =

−= =

∑∑

Page 72: Statistical advices for biologists

72 Statistical advices

(14.5)

In the above example we have to run the F-test with 1/2*18 degrees of

freedom for the error and 1/2*2 df for the treatment. This gives p(F=14.324;9,1)

= 0.202. There is no significant difference between the treatments. Another possi-

bility is of course to use a Bonferroni correction and to divide the test wise error

level through the number of treatments: 0.05 = 0.05/3 = 0.017. A third possibility

is to use the conservative ANOVA with (n-1) dferror and only one dftreat.

Up to know we dealt with such experimental designs where for all combi-

nations of variables at least 2 cases were available (the variances could be calcu-

lated). In this case we speak of complete designs. However, often we have only

incomplete designs where not for all factor combinations within variances exist.

1k 1

ε =−

Growth Light Nutrients0.52 high P1.38 high P0.85 high P0.00 high P1.63 high P2.20 high P0.87 high P0.74 high P0.65 high P4.05 medium N3.12 medium N3.97 medium N6.55 medium N2.72 medium N5.07 medium N7.52 medium N5.94 medium N7.94 medium N3.30 medium N8.99 low Fe10.34 low Fe6.28 low Fe4.93 low Fe6.54 low Fe8.48 low Mn6.79 low Mn6.91 low Mn3.91 low Mn6.02 low Mn

Person Morning Afternoon Night Mean persons Squares1 104 119 102 108.2 90.22 104 96 95 98.3 0.13 84 114 96 98.0 0.44 97 114 92 101.1 5.95 81 111 95 95.5 10.26 108 116 88 104.3 31.67 89 96 93 92.6 36.58 82 96 85 87.9 116.69 84 129 91 101.2 6.410 95 120 84 99.7 1.0

Mean within 92.8 111.0 92.2Grand mean 98.7 sum 299.0SSbetween k=3 897.0df

Squares 20.2 106.8 34.2

29.1 3.5 12.4196.8 246.3 2.818.5 168.6 75.3

203.8 230.4 0.815.4 145.9 255.912.1 9.9 0.130.4 69.3 7.9

310.3 747.1 94.521.1 410.7 245.7 Sum

SSwithin 857.6 2138.4 729.6 3725.6df 20.0

34.8 152.4 41.6 228.8SStreat n=10 2288.0df 2.0

Squares 2.0 4.0 0.4

127.5 202.3 8.666.1 11.2 22.92.5 0.4 5.070.2 8.0 30.796.4 0.1 91.2 5.8 84.6 46.0 0.1 16.2 13.2

137.3 224.6 10.7 1.7 62.7 85.2

SSerror Sum 1437.6 Grand SS 4622.6df 18.0 SSwithin+SSbetween 4622.6

SSwithin 3725.6F 14.324 SStreat+SSerror 3725.6p(F) 0.067

Person Morning Afternoon Night Mean persons Squares1 -4 10 -6 0.0 0.02 5 -2 -4 0.0 0.03 -14 16 -2 0.0 0.04 -4 13 -9 0.0 0.05 -14 15 -1 0.0 0.06 4 12 -16 0.0 0.07 -3 3 0 0.0 0.08 -6 8 -3 0.0 0.09 -18 27 -10 0.0 0.010 -5 20 -16 0.0 0.0

Mean within -5.9 12.3 -6.4Grand mean 0.0 sum 0.0SSbetween k=3 0.0df

Squares 20.2 106.8 34.2

29.1 3.5 12.4196.8 246.3 2.818.5 168.6 75.3

203.8 230.4 0.815.4 145.9 255.912.1 9.9 0.130.4 69.3 7.9

310.3 747.1 94.521.1 410.7 245.7 Sum

SSwithin 857.6 2138.4 729.6 3725.6df 20.0

34.8 152.4 41.6 228.8SStreat n=10 2288.0df 2.0

Squares 2.0 4.0 0.4

127.5 202.3 8.666.1 11.2 22.92.5 0.4 5.070.2 8.0 30.796.4 0.1 91.2 5.8 84.6 46.0 0.1 16.2 13.2

137.3 224.6 10.7 1.7 62.7 85.2

SSerror Sum 1437.6 Grand SS 3725.6df 18.0 SSwithin+SSbetween 3725.6

SSwithin 3725.6F 14.324 SStreat+SSerror 3725.6p(F) 0.067

Page 73: Statistical advices for biologists

Statistical advices 73

For instance, we study our already known plants within

the following design. We have three light categories (low,

medium, high) and four nutrient categories (P, N, Fe, Mn)

We we do not expect that light and nutrients interact. That

mean we ignore the interaction term light x nutrients.

Therefore, instead of at least 24 parallels (3*4*2) we need

much less. In the best case only eight. You don’t need all

treatment combinations to be realized. In other words ig-

noring irrelevant interactions reduces the experimental

effort. In the example beside we considered only the main

effects and found only light to be significant.

Essentially, the incomplete design ANOVA proceeds

similar to the ANOVA for complete designs. SSerror are

calculated in the same way as above. SStreat contains the

between treatment variances of the factors.

A special case of incomplete designs are nested designs. In nested designs occur treatments of one factor

only with certain treatments of the other factor. An example gives the next table. Phosporus occurs only in the

soils of the experiments that got much light, nitrogen is associated with the medium light treatment and Fe and

MN with the low light treatments. Within the variance components module of Statistica we use the nested de-

sign option and get the output shown above. Again only light appeared to be significant.

Lastly we look at the F-test from the perspective of a multiple regression. A a simple ANOVA F is de-

fined as

R2 of the multiple regression is defined as

where streat

2 is of course the variance explained by the predictor variables. We further know that SStotal = SStreat

+ SSerror. Plugging this equation into the second gives

Now we go back to the first equation and get

(7.21)

This equation is identical to eq. 6.12 (with m = k-1 and enables us to test the significance of a multiple

and a bivariate regression.

treat

error

SS (n k )FSS (k 1)

−=

22 treat treat

2total total

SSRSS

σ= =

σ

2total treat error total total error

2error total

SS SS SS SS R SS SS

SS (1 R )SS

= + → =→ −

= −

2 2total

2 2total

R SS (n k) R (n k)F(1 R )SS (k 1) (1 R ) (k 1)

− −= =

− − − −

Page 74: Statistical advices for biologists

74 Statistical advices

7.2 Comparisons a priori and a posteriori

When planning experiments or using experimental data you have to be sure what you want to do. Do

you intend to use experiments for pattern seeking to get new hypotheses or do you want to verify a priori de-

fined hypotheses. In the first case you explain a result a posteriori with a new hypothesis, in the second case

you accept or reject an apriori formulated hypothesis. Both processes have to be distinguished clearly. Formu-

lating and testing the same set of hypothesis within one experimental design is logically and mathemati-

cally not acceptable.

For instance, you compare a strain of genetically modified bacteria with the wild form. You might use a

t-test and find significant differences in metabolism rates. From this you formulate the hypothesis that the ge-

netic modification influence metabolism rates. You used statistics to get an a posteriori hypothesis. But you did

not prove this hypothesis using statistics. However, you might also have biochemical data at hand and predict

that the genetic modification should cause different metabolism rates. You undertake an experiment and use a

statistical test to verify your hypothesis. In the latter case the information gain by using the t-test is much higher

then in the first case.

The distinction between a priori and a posteriori comparisons has profound implications for the use of

certain test statistics. For a priori comparisons no corrections of significance values seem to be necessary. In

the case of a posteriori comparisons instead our probability levels to make type I errors might be biased. We

undertake pattern seeking. Our brain is constructed in such a way that it always tries to find patterns. Hence, the

probability to see something is much higher than to see nothing. This is the reason for our inclination to all

sorts of metaphysics or superstition.

An important method for the correction of α-error levels in the analysis of variance is the Scheffé test.

The Scheffé test verifies all pairwise comparisons of an ANOVA at the experiment wise α-level. The test

guarantees that no pairwise comparison can be significant at an error level higher than α.

Page 75: Statistical advices for biologists

Statistical advices 75

8. Cluster analysis

Cluster analysis is one of the multivariate techniques that is not based on the assumptions of the general

linear model. Cluster analysis is a method that does not test hypotheses. It is an intrinsically hypotheses gen-

erating method. Simply speaking a cluster analysis tries to classify a set of objects into groups (cluster or

classes) according to a predefined measure of distance. However, there is no single technique. Cluster analysis

is a whole set of very different methods and solutions.

Consider the following example. We take a matrix con-

taining ten variables (objects) and 20 observations (cases).

Then we start Statistica, copy the data into the cluster

analysis module and perform a default analysis. The result

(the Figure beside) is a dendrogram that visualizes the

distances of the variables from each other according to a

linkage algorithm. We are ready at hand with an interpre-

tation. An a posteriori hypothesis generating process.

But what did Statistica really do? First of all it applied a measure of distance. The program measures

case wise differences and computes from them a common distance value between two variables. It then tries to

link variables according to these distances. The Jaccard measure of similarity is one measure of distance be-

tween two objects. It is defined as

(8.1)

where a is the number of common elements and b and c the total numbers of elements in object 1 and 2.

It is possible to generalize the Jaccard index to get an equation that contains nearly all measures of simi-

larity as special cases

(8.2)

where a is the number of common elements, b and c are the number of elements that occur only in object 1 or 2

and e is the number of elements that neither occur in 1 nor in 2.

The best known measure of distance for metrically scaled variables is of course the Euclidean distance.

(8.3)

where p is the number of data sets and xik and xjk the values of i,j at data point k.

The most important alternative to Euclidean distance is the so-called city block or Taxi driver distance

that measures the shortest way to get from point i to point j. It is defined from the general Minkowski metric

(8.4)

aJb c

=+

( )a eJ

a e b cε

ε δ+

=+ + +

2

1

( )p

ij ik jkk

d x x=

= −∑

1/

1

rp r

ij ik jkk

d x x=

⎛ ⎞= −⎜ ⎟

⎝ ⎠∑

Variables

Dis

tanc

e

1.20

1.25

1.30

1.35

1.40

1.45

1.50

1.55

1.60

VAR8 VAR4

VAR10 VAR3

VAR7 VAR6

VAR9 VAR5

VAR2 VAR1Fig.8.1

Page 76: Statistical advices for biologists

76 Statistical advices

r =1 defines the Taxi driver distance, r = 2 the Euclidean distance. Another measure of distance for metrically

scaled variables is the use of pairwise correlation coefficients or the Bray-Curtis measure dealt with in Chapter

5.

More important for the outcome of a cluster analysis is the choice of the linkage algorithm. The basic

procedures of such algorithms can be exemplified from the single linkage algorithm (Fig. 8.2). Starting with

an association matrix we order the pairs of sites according to the degree of association. Then step by step ob-

jects are including into cluster that have a higher association than predefined. The first group is made of BD,

the second group includes C because D and C are the next with respect to association. Lastly we include A.

Single linkage has some undesired properties. It tends to produce a large number of clusters and has problems

if three or more objects have the same distances to each other.

The Figure 8.3 shows the most important linkage algorithms. The exact form of the algorithms are given

in most statistical textbooks. Important is that different algorithms frequently result in different clusters. The

result of a cluster analysis relies therefore to a good deal on the choice of the linkage algorithm. In general

Clusteralgorithm

Hierachical algorithms Partition algorithms Optimization algorithms

agglomerative divisive

Single linkage

Averagelinkage Median Ward

Changingalgorithms

Iterativeminimalization

Clusteralgorithm

Hierachical algorithms Partition algorithms Optimization algorithms

agglomerative divisive

Single linkage

Averagelinkage Median Ward

Changingalgorithms

Iterativeminimalization

DB

DC

D

C

B

A B C D DB 0.9

A 1 DC 0.8

B 0.3 1 DA 0.6

C 0.2 0.4 1 CB 0.4

D 0.6 0.9 0.8 1 BA 0.3

CA 0.2

BA

B

A

D

B

C

A

Similarity

Similarity

Fig.8.3

Fig.8.2

Page 77: Statistical advices for biologists

Statistical advices 77

we have four types of algorithms

1. Sequential versus simultaneous algorithms. In simultaneous algorithms the final solution is ob-

tained in a single step and not stepwise as in the single linkage above.

2. Agglomeration versus division algorithms. Agglomerative procedures operate bottom up, divi-

sion procedures top down

3. Monothetic versus polythetic algorithms. Polythetic procedures use several descriptors of link-

age, monothetic use the same at each step (for instance maximum association).

4. Hierarchical versus non-hierarchical algorithms. Hierarchical methods proceed in a non-

overlapping way. During the linkage process all members of lower clusters are members of the

next higher cluster. Non hierarchical methods proceed by optimization within group homogene-

ity. Hence they might include members not contained in higher order cluster.

There are some general properties of the linkage algorithms.

1. The single linkage algorithm uses the minimum distance between the members of two clusters

as the measure of cluster distance. It favours chains of small clusters.

2. The average linkage uses average distances between clusters. It gives frequently larger clusters.

The most often used average linkage algorithm is the Unweighted Pair-Groups Method Aver-

age (UPGMA).

3. The Ward algorithm calculates the total sum of squared deviations from the mean of a cluster

and assigns members as to minimize this sum. The method gives often clusters of rather equal

size.

4. Median clustering tries to minimize within cluster variance.

0

1

2

3

4

5

6

7

8

VAR8 VAR7 VAR5 VAR4 VAR3 VAR2 VAR6 VAR10.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

VAR8 VAR7 VAR5 VAR4 VAR3 VAR2 VAR6 VAR1

0

1

2

3

4

5

6

VAR8 VAR7 VAR5 VAR4 VAR3 VAR2 VAR6 VAR10.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

5.0

VAR8 VAR7 VAR5 VAR4 VAR3 VAR2 VAR6 VAR1

Fig.8.4

Page 78: Statistical advices for biologists

78 Statistical advices

The Figure 8.5 shows the same set of eight variables clustered by four different linkage algorithms. The

results look different. Only two constant patterns are detectable. Variables 1, 2, 3, and 6 cluster always together

and variable 8 seems to form a single cluster. It is then a question of our interpretation of the results. Most

popular are UPGMA and the Ward algorithm that gives in most cases rather equally sized partitions and

therefore clusters.

The Ward algorithm differs somewhat from the others by using a minimalization criterion. Using

Euclidean distance the Ward algorithm tries to minimize for each cluster r the distance dr2 of all elements of r

from the centroid (the middle) c of the cluster.

(8.5)

One method to assess the ‘right’ number of clusters is the so-called elbow test. The next Table shows

the agglomeration process of ten variables. The final clustering indicates seven singles cluster. However, some

of them seem to be poorly separated. We plot the Euclidean distances against the agglomeration stage as shown

below. From stage seven to eight a step (an elbow) occurs, where the dissimilarity suddenly raises. At lower

stages dissimilarities are rather low. The elbow criterion tells now that we should accept only those clusters

above the elbow. Hence we should accept a three cluster solution with cluster one containing Var2, Var4, Var5,

and Var9, cluster two containing Var6 and Var8, and cluster three containing Var1, Var3, Var7, and Var10.

However, there is no ‘correct’ clustering. Each method favours different aspects of distance. Hence,

2n k2

r ij ri 1 j 1

d (x c ) min= =

= − →∑∑

Agglomeration process Ward method Stage Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr Obj. Nr

1 2 3 4 5 6 7 8 9 10 1 0.82 VAR5 VAR9 2 0.85 VAR2 VAR5 VAR9 3 0.87 VAR1 VAR10 4 1.02 VAR6 VAR8 5 1.17 VAR2 VAR5 VAR9 VAR4 6 1.40 VAR1 VAR10 VAR3 7 1.71 VAR1 VAR10 VAR3 VAR7 8 3.13 VAR1 VAR10 VAR3 VAR7 VAR6 VAR8 9 5.08 VAR1 VAR10 VAR3 VAR7 VAR6 VAR8 VAR2 VAR5 VAR9 VAR4

Euclidean distances

0.00

1.00

2.00

3.00

4.00

5.00

6.00

0 1 2 3 4 5 6 7 8 9 10Stage

Squ

ared

Euc

lidea

n di

stan

ceco

effic

ient

s

Ward MethodEucl idean distances

100 D / Dmax

VAR4

VAR9

VAR5

VAR2

VAR8

VAR6

VAR7

VAR3

VAR10

VAR1

30 40 50 60 70 80 90 100 110

Fig. 8.5 Fig. 8.6

Page 79: Statistical advices for biologists

Statistical advices 79

although cluster analysis is a genuine hypothesis generating technique we should again start with a

sound and realistic hypothesis.

8.1 Advices for using a cluster analysis: • The first point is the number of data sets. Especially in the case of samples where you want to

get information about the whole population sample sizes (data sets) must not be too small.

• Screen the data for outliners. They might have overproportional influence on the outcome and

should be eliminated.

• As in other multivariate techniques an initial sound hypothesis building process helps to interpret

the results.

• It is a good praxis to undertake in parallel a factor analysis and to compare the results with those

of the cluster analysis. Sometimes (in the case of many variables) it is better to undertake first a

factor analysis and use the factor loadings instead of the raw variables for the cluster analysis. By

this technique highly correlated variables are combined and the total number of variables is re-

duced.

• Even without a priori factor analysis variables that correlate highly with others (r > 0.9) should

be eliminated. It is of course our interpretation which of the two or more correlated variables to

throw out.

• If all data are metrically scaled I advise to standardize them by Z-transformation. Large differ-

ences in absolute values might bias the outcome. Try also log-transformations.

• Try out several linkage algorithm. Compare the results and accept only clusters that have been

found by all or at least by the majority of algorithms.

• Do the results make sense? Compare them with your initial hypotheses.

• If you have a large data set of independent data you might divide them into two randomly chosen

parts. Use one part in the cluster analysis for hypothesis building and the second part for verify-

ing the result by using the same algorithm.

• Cluster analysis is a method that is open’ for all types of data manipulation. Therefore, you must

always give basic information about how you received a given result:

1. Distance measure and linkage algorithm

2. Explain your method choice. Tell especially, why you used a given linkage algorithm

3. Tell whether your results are stable.

Page 80: Statistical advices for biologists

80 Statistical advices

8.2 K-means cluster analysis Ordinary cluster analysis groups a set of variables into a number of clusters. This number is the result of

the clustering process. A different technique is the clustering of variables into a predefined number of

clusters. This is done by the k-means clustering. k-means clustering starts with a predefined number of clusters

and puts the elements step by step into these clusters. It seeks for elements that have distances from the mean

of the own cluster that are larger than those to another

cluster. The element is then shifted to this cluster. The

process stops if all elements have found ‘their’ cluster.

The k-means method does not result in a dendro-

gram. Instead the output contains the distances of each

variable from the cluster mean. The results but can be

visualized by distances of elements from cluster means.

This is shown in the diagram beside. 20 Elements have

been grouped into five clusters. They are defined by

distances of cluster centres (the red arrows) and these are

computed from the elements they contain (black ele-

ments).

The k-means method is a good alter-

native to the previous hierarchical

approach if the number of clusters is

a priori known. This is often not the

case. Then you can first run an ordi-

nary cluster analysis. This gives a

hypothesis about the number of clus-

ters. You then run a k-means analysis

to reach in a better cluster model.

The Figure beside shows a plot of

cluster means for each data set of a k-

means cluster analysis of eight vari-

ables and ten data sets divided into

three clusters. Such a plot helps to assess how well the clusters are separated. In our case the red and the green

cluster are weakly separated.

A shortcoming of this method is that the final clustering might depend on the entry order of the ele-

ments into the clustering process. I advise therefore to run several analyses in which the order of variables is

changed. Accept the solution that was found most often.

Przyp

-2

-1

0

1

2

3

4

1 2 3 4 5 6 7 8 9 10

A A

A A

A A

A

A

A

A

AAA

AA

AA

A

A

A

Page 81: Statistical advices for biologists

Statistical advices 81

15.3 Neighbour joining

The most often used agglomerative cluster algorithm in phylogenetic analysis

is neighbour joining that was particularly developed for phylogenetic analy-

sis.

At the beginning the method puts all elements into different clusters (Fig.

8.3.1). It then proceeds stepwise. It starts with a dissimilarity matrix based on

a certain distance measure. (shown as different branch lengths in the Fig.).

First, two clusters (elements) are chosen and combined in one cluster to get a

new node in the tree (X in the Fig.). From this a new dissimilarity matrix

(containing the elements A, X, D, E, F) is calculated and the method proceeds

at step one. The third dissimilarity matrix contains the elements (A, X, Y, F).

The method depends therefore on three criteria: the algorithm to choose the

pair of elements to join, the algorithm to calculate the dissimilarity matrix and

an algorithm to estimate branch lengths. In the simplest case dissimilarities

for any element are calculated from

(8.3.1)

δ(X,Y) are the dissimilarities for the elements X and Y calculated from the

branch lengths. To select a pair of elements to be joined the method proceeds

in calculating

(8.3.2)

for all element pairs (X,Y). The pair with the lowest value

of Q is selected for joining. Given that two elements A and

B have been selected and joined to a new element UAB the

new dissimilarities are calculated from

(8.3.3)

This is called the reduction step. After this step the meth-

ods proceeds in a recursive way starting again from the

dissimilarities. Beside I show a simple example for four

species. From an initial distance matrix dissimilarities (eq.

8.3.1) were calculated. The next step involves the selection

of elements (eq. 8.3.2) and at last the reduction to a new

distance matrix (eq. 8.3.3). This procedure is then repeated

for the new matrix. At the end the methods joins verte-

brates and Protostomia.

We also need the branch lengths of U to A and B. These

in

(X) (X,Y )Δ = δ∑

(X,Y)Q (n 2) (X,Y) (X) (Y)δ = − δ −Δ −Δ

AB(X, A) (X, B) (A, B)(X, U )

2δ + δ − δ

δ =

A

F

DE

C

B

Root

A

F

DE

C

B

RootX

A

F

DE

C

B

RootX

YFig. 8.3.1)

Distance matrixMouse Raven Octopus Lumbricus

Mouse 0 0.2 0.6 0.7Raven 0.2 0 0.6 0.8Octopus 0.6 0.6 0 0.5Lumbricus 0.7 0.8 0.5 0

Delta values 1.5 1.6 1.7 2

Q-valuesMouse/Raven -2.7Mouse/Octopus -2Mouse/Lumbricus -2.1Raven/Octopus -2.1Raven/Lumbricus -2Octopus/Lumbricus -2.7

Distance matrixMouse Raven Protostomia

Mouse 0 0.2 0.4Raven 0.2 0 0.45Protostomia 0.4 0.45 0

Delta values 0.6 0.65 0.85

Q-valuesMouse/Raven -1.25Mouse/Protostomia -1.05Raven/Protostomia -0.6

Distance matrixVertebrata Protostomia

Vertebrata 0 0.075Protostomia 0.075 0

Page 82: Statistical advices for biologists

82 Statistical advices

are given by

(8.3.4)

Above a more complicated example with the program Past is shown. Starting with raw data the program

first calculates the distances between the species (in this case from correlation coefficients) and then proceeds

as shown above.

A very good and simple introduction to neighbour joining gives http://artedi.ebc.uu.se/course/sommar/

njoin/index2.html.

( n 2 ) (A , B ) (A ) (B )(A , U )2 (n 2 )

(n 2 ) (A , B ) (A ) (B )(B , U )2 (n 2 )

− δ + Δ − Δδ =

−− δ − Δ + Δ

δ =−

Page 83: Statistical advices for biologists

Statistical advices 83

9. Factor analysis In the last years factor analysis has become very popular among biologists. The reason is surely its ease

in use and its ability to generate interpretable hypotheses. Additionally it generates new artificial variables (the

factors) that can be used in further analysis for instance in indicator species analysis or multiple regression.

On first sight factor analysis seems to be quite similar to cluster analysis. Both methods group variables

into clusters of more or less similar elements. But there is an important difference. Factor analytical methods

use correlation matrices and rely on the general linear model.

Factor analysis is not a single method, it is a general name for a multitude of different techniques. And

this large number of techniques makes factor analysis to a rather dangerous method in the hand of inexperi-

A B C D E F G H I J

F1 F2 F3

r

Fig. 9.1

Fig. 9.2

A

123456

123456

B C D E

z1a

z2a

z3a

z4a

z5a

z6a

z1b

z2b

z3b

z4b

z5b

z6b

z1c

z2c

z3c

z4c

z5c

z6c

z1d

z2d

z3d

z4d

z5d

z6d

z1e

z2e

z3e

z4e

z5e

z6e

F1 F2

f11

f21

f31

f41

f51

f61

f12

f22

f32

f42

f52

f62

Z-transformedData matrix Z

Z-trans-formedFactorvalues b

Cases n

Variables V

Factors F

rFV = aFVFactorloading

j2i,k

k 1a

Communality=

=∑

F1 F2

A

B

C

D

E

aa1

ab1

ac1

ad1

ae1

aa2

a22

ac2

ad2

ae2

i2k, j

k 1a Eigenvalue

=

=∑F=Z•bn

61 6k k1k 1

f z b=

∑i

F1A F1 Ak 1

r z z=

= ∑

Page 84: Statistical advices for biologists

84 Statistical advices

enced users who are not aware of the many pitfalls.

Starting point of any factor analysis is a data matrix of variables and cases. Factor analysis does not dis-

tinguish between dependent and independent variables. Our question is how are the variables related? We have

two possibilities. Either the variables are intercorrelated or there are other hidden variables, the factors, that

influence our observed variables. A regression analysis would deal with the first hypothesis. Factor analysis

assumes a priori that we have hidden factors. This is graphically shown in Fig. 9.1. A series of variables A

to J is influenced by three main factors. These factors cluster our variables. Factor 1 mainly influences A to D,

factor 2 variableas C to H and factor 3 variables F to J. Note that influences overlap. Aim of the analysis is to

define and interpret these factors. Factor analysis groups therefore variables according to their correlations with

these factors. It is then our problem to interpret these factors.

Fig. 9.2 shows the essentials of a factor analysis in more detail. We start with a data matrix containing

six cases and five initial variables. These variables are for convenience Z-transformed, hence have a mean of 0

and a variance of 1. The aim of the factor analysis is now to find new variables F and its respective factor val-

ues fij for each case. Similar to multiple regression this is done from a linear combination of the z-values with

known weights b.

In general we have the systems of linear equations

(9.1)

The aim is to infer b and F is such a way that they predict Z best.

We can now use the correlation of the predicted f values with the initial z values. Because the f values

are also Z-transformed we have

This correlation is a measure of distance and describes how close a variable is dependent on a factor.

The correlation is called factor loading. The main output of a factor analysis is a matrix that gives the factor

loading for each factor on each variable. The values aij2 are of course coefficients of determination and give the

proportion of total variance of i that is explained by the new factor j. The sum of all aij2 should ideally equal the

total variance of i. Because factor analysis uses Z-transformed input values this variance is one. Hence

(9.2)

This sum is called communality. Because we intend to reduce the number of variables the maximum commu-

nality is frequently lower than 1, that means the new factors let part of the total variance of a variable unex-

n

ij ik kjk 1

f z b=

= ∑

11 1j 11 1j11 1n

n1 nj n1 njk1 kn

f ... f b ... bz ... z... ... ... ...... ...

F Z b... ... ... ...... ...f f b ... bz ... z

⎛ ⎞ ⎛ ⎞⎛ ⎞⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟= = • = •⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟

⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠⎝ ⎠ ⎝ ⎠

k

ij ij kj kin 1

1r a f zn 1 =

= =− ∑

ksij

i 10 a 1

=

≤ ≤∑

Page 85: Statistical advices for biologists

Statistical advices 85

plained.

The sum of the factor loading aij2 is the same as the sum of

the part of variance that is explained by a certain factor. From eq.

5.28 we learned that these are the eigenvalues λ of the factor

(eigenvector) j .

(9.3)

If we divide the eigenvalue through the number of variables

we get the fraction of total variance each factor explains.

We can show the main task of a factor analysis graphically (Fig. 9.3) We have two sets of data that can

be arranged in a (x,y) coordinate system. The aim is now to find new axes, the factors, in such a way that all

data points are closest to these axes. If the axes are orthogonal we speak of a canonical or principal compo-

nent analysis (PCA) and the factors are identical to the eigenvectors of the matrix. This is the most often met

type of factor analysis and the easiest to interpret because our axes are independent. In our example we turn the

system by an angle of α and get two new axes. Both data a close to these new axes. Hence each set is now ex-

plained by one factor instead of the previous two. Mathematically we have to minimize the variance of our data

according to these new axes. In a PCA these new axes (eigenvectors) are orthogonal and therefore independent.

They explain successively the maximal explainable variance. Further the higher the original variables were

correlated the fewer new factors we need to explain total variance. To solve eq. 9.1 we now go back to the re-

gression section.

Further we are looking for such vectors that are closest to the initial variables. Hence wee need

where S is the diagonal matrix with the standard deviations si and sj. b is the matrix of major axis (factors) of

the system and λ are the associated eigenvalues.

From Fig. 9.2 we see that factors loadings (the correlations between factors and initial variables), factors

and variables are connected in an elementary way.

The basic assumption of factor analysis is that Z

can be expressed by a linear combination of the

factor loadings a and the factor values F

In matrix notation

ns

j iji 1

aλ=

= ∑

1R Z' Zn 1

= •−

S R S( I) b 0Σ = • •Σ − λ • =

i

F1A F1A F1 Ak 1

r a Z Z=

= = ∑

i

j 1 j 1 2 j 2 3 j 3 kj kk 1

Z a F a F a F ... a F=

= + + = ∑

x

y α

dij

Fig. 9.3

3 -44 3

3 4-4 3

25 00 25

1 00 1

F

F'

F'.F

1/25 F'.F

Symmetric matrix2 1 31 2 43 4 2

EigenvalueEigenvectors-2.55287 0.361491 0.805415 0.4697141.043238 0.569317 -0.58963 0.5728977.509629 -0.73838 -0.06032 0.671684

Transpose of eigenvectors0.361491 0.569317 -0.738380.805415 -0.58963 -0.060320.469714 0.572897 0.671684

Product1 0 00 1 00 0 1

Page 86: Statistical advices for biologists

86 Statistical advices

We used the fact that the factors are not correlated. What does this mean. Factors are not correlated when they

are orthogonal. Then the increase in one factor is not associated with the increase in the other. This is shown

above in a simple two dimensional example. Hence that means F•F’ = cI with c being a constant. At the end

we get

(9.4)

The fact that the dot product of a matrix of orthogonal vectors with its transpose gives the identity ma-

trix is important and also used in other eigenvalue techniques. What type of matrices yield orthogonal eigen-

vectors? The Excel example above shows that symmetrical matrices gives orthogonal eigenvectors. The dot

product of the matrix of eigenvectors with its transpose yields the identity matrix. Non-symmetrical matrices do

not give identity matrices. The most important matrices in statistics are of course distance matrices, particularly

correlation matrices that are symmetrical.

Eq. 9.4 gives the relation between the original correlation matrix and the matrix of factor loadings. It is

called the fundamental theorem of factor analysis. The problem is now to find such a matrix a with such a

number of dimensions (factors) that is closest to R.

Recall that eigenvectors are the major axis of ellipsoids. Hence these should be the new axes (factors)

we are looking for. From the definition of eigenvalues and eigenvectors we also get a method to compute the

total variance explained by each factor. We have to solve

(3.5)

As a result a factor analysis weights how much each factor contributes to the variance of each variable.

These weights are the factor loadings and are nothing more than correlation coefficients of the factors with

the variables. The resulting factors are independent of each other and explain successively the total vari-

ance.

A factor analysis proceeds therefore in four main steps. The first step is the computation of a correlation

matrix. The next step is to arrange the variables into an n-dimensional space in such a way that the distances of

all variables to the axes of the space become minimal. The problem is to find a solution where i, the number of

factors (dimensions), is minimal. The third step is to rotate the whole i-dimensional space around its axes in

such a way that the variables range even more close around them. This is equivalent to the calculation of the

eigenvectors. The loadings of each variable are than nothing more than inverse measures of distance. The

closer a variable lies to an axis, the higher loads the factor to this axis.

At each step of the analysis we have to decide about principle ways of computation. In a first step we

might decide whether we use raw data or Z-standardized data with mean 0 and variance 1. In many cases

the latter way is preferable.

The next problem is to define how much of total variance the factors should explain. In fact eq 9.4

should be written different

1 1Z F a ' R (F a ') ' F a ' a F ' F a 'n 1 n 1

1 cR a cI a ' a a 'n 1 n 1

= • → = • • • = • • • →− −

= • • = •− −

R a a '∝ •

i i[R I] u 0− • =λ

Page 87: Statistical advices for biologists

Statistical advices 87

Factor loadings Principal component analysis Factor Factor Factor Factor Factor 1 2 3 4 5 VAR1 0.044986 0.068843 -0.16084 0.108102 -0.8891 0.834817 VAR2 -0.77529 0.021258 -0.19047 0.312705 0.11186 0.748102 VAR3 0.078655 -0.90121 0.057582 -0.11802 0.05936 0.839134 VAR4 -0.24078 0.173654 -0.3026 0.327472 0.5965 0.642748 VAR5 -0.06913 -0.11164 0.709716 0.269773 -0.29767 0.682324 VAR6 0.077056 0.019925 0.794834 -0.06372 0.220789 0.690904 VAR7 0.109246 0.794463 0.014581 -0.41113 0.113789 0.825295 VAR8 0.664919 0.143209 0.385821 0.44663 0.013384 0.811141 VAR9 -0.80119 0.054505 0.38998 -0.09042 0.104141 0.815982 VAR10 -0.01219 -0.11989 0.087476 0.875345 0.009453 0.788492 Eigenvalue 1.774087 1.529413 1.601301 1.45039 1.323768 Explained variance 0.177409 0.152941 0.16013 0.145039 0.132377

Commu-nality

(9.6)

The matrix of factor loadings does not explain total variance There is rest variance contained in the ma-

trix E. The problem to assess E is called the communality problem. There are three basic techniques to esti-

mate the communality a priori. If we have no explicit hypothesis about our factors we simply assume that they

together explain 100% of total variance. In this case we perform a principal component analysis. This is the

default option of many statistic packages. We might also estimate the total variance explanation in the course of

an iterative computation. In this case we perform a major axis factor analysis. Finally, we may take the high-

est correlation coefficient between two of the variables as an estimator of the maximum variance explanation of

the factors. This is of course only a rough estimate. Look at the Table above. I used ten variables to conduct a

default principle component analysis with Statistica. The program extracted five factors. If we compute the

sums of the squared factor loadings for each variable we get the communalities. These values range between

0.64 and 0.84. Even a principal component analysis cannot explain the total variance. We would need more

factors. But then most factors would load high only with single variables. Hence, we have to interpret that there

are no hidden variables or that we don’t need to assume them. A simple regression analysis would do the same

job. We also see that the first factor explains 18% of total variance, the fifth factor still 13%. In total the three

factors explain 77% of variance. 23% remain unexplained.

The next step in our analysis is the rotation of axes so that the distances of the variables from the axes

minimize. Again there are several techniques. Important is to differentiate between orthogonal and oblique

rotation techniques. After orthogonal rotation factors remain independent. Otherwise they become corre-

lated. The latter case is difficult to interpret. We should therefore prefer the orthogonal Varimax rotation

method. Additionally, Z-transformed variables should be used. The result is a Table as above that shows a de-

fault principal component analysis with Varimax rotation.

How many factors should we accept as being significant? In our case the maximum number of factors

would be ten. However, we want to find hidden variables. We need therefore a solution where at least two, bet-

ter three or more variables load high with a factor. There are several criteria to find the optimal number of fac-

tors. Most often used is the Kaiser criterion. It says that we should only accept factors that have eigenvalues

'1R a an 1

= • +Ε−

Page 88: Statistical advices for biologists

88 Statistical advices

above 1. Alternatively we may apply a Scree

test, similar to the elbow test of cluster analysis.

This is shown in the Figure 9.4. According to

Cattell factors should be considered as being

significant if they are before the knee of the ei-

genvalue—factor rank order plot. These would

be the first three factors. Additionally, empiri-

cal data should show such a knee. A factor

analysis done with random variables should lack

the knee. In our Table above a distinct knee is lacking. Indeed, the variables used were simple random num-

bers.

Which variables define a factor. Those that load high with a given factor. The question is therefore how

to decide what is high and what not. There is no simple solution to this problem. But there are some valuable

rules.

• A factor might be interpreted if more than two variables have loadings higher than 0.7.

• A factor might be interpreted if more than four variables have loadings higher than 0.6.

• A factor might be interpreted if more than 10 variables have loadings higher than 0.4.

In the Table on the previous page factor 1 loads highly positive with Var 8 and highly negative with

Var2 and Var9. We can try to interpret this factor from these three variables. Factor two loads highly negative

with Var3 and positively with Var7. Factor 3 might be interpreted from Var5 and Var6. However, the remain-

ing two factors are interpretable only on the basis of the high loading single variables.

Prior to PCA we should infer whether it makes sense to do so. Is our data matrix appropriate? This can

be assessed by the Bartlett test that tests whether the intercorrelations of the variables are sufficient to give

room for common factors behind them. Particularly, the tests uses the

null hypothesis that the distance matrix is the identity matrix that

means that all of diagonal elements are zero (no correlation or maxi-

mum distance). We calculate

(3.6)

where k is the number of variables and n the number of observations.

v is χ2 distributed with k(k-1)/2 degrees of freedom.

The Excel example beside shows a correlation matrix of k = 6 vari-

ables. The identity matrix gives the CHI2 probability of 1 for H0. The

second example shows how to use the Bartlett test to assess necessary

sample sizes. At even moderate mean pairwise correlations you would

need at least 30 cases to detect a significant structure (at p(H0) <

0.05). Most textbooks advise not to use factor analysis with fewer

than 50 cases irrespective of the number of variables..

2k 5v (n 1 ) ln( R )6+

= − − −

01234567

0 1 2 3 4 5 6 7 8 9 10

Factors

Eig

enva

lues

Random variables

Empirical variables

Scree test limit

Fig. 9.4

Distance matrixA B C D E F

A 1 0 0 0 0 0B 0 1 0 0 0 0C 0 0 1 0 0 0D 0 0 0 1 0 0E 0 0 0 0 1 0F 0 0 0 0 0 1

Det C 1

n 50k 6

Bartlett v 0df 15Chi2 1

Distance matrixA B C D E F

A 1 0.3 0.3 0.3 0.3 0.3B 0.3 1 0.3 0.3 0.3 0.3C 0.3 0.3 1 0.3 0.3 0.3D 0.3 0.3 0.3 1 0.3 0.3E 0.3 0.3 0.3 0.3 1 0.3F 0.3 0.3 0.3 0.3 0.3 1

Det C 0.42

n 31k 6

Bartlett v 25df 15Chi2 0.05

Page 89: Statistical advices for biologists

Statistical advices 89

9.1Advices for using factor analysis: • Your data have to be of the metric type.

• Make sure that the assumptions of the GLM are not strongly violated. In doubtful cases use log-

transformed variables

• Try independent analyses with raw and z-transformed data sets. The results should be qualita-

tively the same.

• Use a principal component analysis with Varimax rotation. This makes interpretation easier.

• Use the Scree criterion for identifying the maximum number of significant factors.

• In the case of missing values whole cases should be excluded.

• The number of cases should be at least twice as large as the number of variables. Never use ma-

trices where the number of cases is less than the number of variables.

• If you have enough data sets divide them randomly into two groups and perform for each group

an analysis. Interpret your factors only when both results are identical.

Factors are new vari-

ables (Fig. 9.2) and come

from Z = F•b. They have fac-

tor values (independent of

loadings) for each case. These

factors can now be used in

further analysis, for instance

in regression analysis. This

method is especially useful

when dealing with a manifold

of variables which are highly

correlated. In this case you

should use a factor analysis to

generate new artificial vari-

ables (but with meaningful interpretations) and undertake then a multiple regression. The PAST example

above shows the original data, the respective eigenvalues and a diagram of factor loadings. Factors values for

each case are scattered and printed.

Factor analysis can also be used to cluster cases. However, in factor analysis the number of variables to

be clustered should always be larger than the number of cases. Therefore, for factorizing cases you would need

many variables. Nevertheless, sometimes such a procedure is a good alternative to cluster analysis.

Page 90: Statistical advices for biologists

90 Statistical advices

10. Canonical regression analysis Multiple regression establishes linear relationships between a set of independent (predictor) variables

and one dependent variable. Canonical regression analysis is a generalisation of multiple regression and

deals with several dependent variables. We have therefore two sets of variables and get not a single but several

regression functions. The number of functions equals the number of variables in the smaller set. The method is

called canonical because only linear dependencies are assumed.

The principles of a canonical regression analysis are simple. First, you run two principal component

analyses, for the set of dependent and for the independent variables. Next, you rotate the factor axes in such a

way that the first factor of the independent variables set correlates maximally with the first factor of the de-

pendent set. Hence, canonical regression analysis is a correlation analysis that uses principle component fac-

tors.

The interpretation of a canonical regression analysis is difficult. The Table above shows a combined

output of the Statistica software package. I used 12 variables and 30 cases. The first four variables constituted

the set of dependent and the last eight variables the set of independent variables.

Statistica gives for both sets four roots, according to the number of variables in the smaller set. As in

multiple regression the regression coefficients (weights) should take values between –1 and 1, but as for beta-

weights values larger than 1 or smaller than –1 are possible. Such cases point always to violations of the gen-

eral linear model, especially to high levels of multicollinearity. As in ordinary regression analysis high levels

Canonical regression analysis results Canonical R 0.82 CHI2(32) 57.7 p 0.004 Regression coefficients Predictors Root 1 Root 2 Root 3 Root 4 Var 1 -0.58819 0.341623 0.710683 -0.49699 Var 2 -0.38425 -0.08823 0.40191 -0.73306 Var 3 -0.41799 0.653184 0.078462 0.385908 Var 4 -0.38081 -0.92348 -0.70002 0.459424 Var 5 0.012453 -0.08183 -1.02332 0.115108 Var 6 -0.41992 0.634172 0.044209 -0.79315 Var 7 -0.73958 0.320323 -0.41184 -0.07587 Var 8 0.022575 0.011094 -0.11499 -0.35833 Predicants VAR 1 0.057528 -1.15332 0.081897 0.200481 VAR 2 -0.38791 -0.7864 -0.70295 -0.47974 VAR 3 -0.48525 -0.1507 0.780028 -0.41578 VAR 4 0.928718 0.134346 0.21516 -0.4467 Eigenvalues 0.683835 0.620702 0.33699 0.033358 Predicators Variance explained 0.21698 0.147743 0.233063 0.402214 Redundancy 0.148378 0.091704 0.07854 0.013417

Predicants Variance explained 0.109118 0.139378 0.096843 0.134036 Redundancy 0.074618 0.086512 0.032635 0.004471

Page 91: Statistical advices for biologists

Statistical advices 91

of multicollinearity (pairwise r > 0.9) makes it often very difficult to interpret the results.

It seems that in the first root the variables seven and one contribute most to the first root in the second

set that loads high with VAR 4. In the second root variables 3 and 6 seem to be positively and variable 4 nega-

tively correlated to root 2 of the dependent variables set. VAR 1 and VAR 2 contribute negatively to this root.

It depends on us how to interpret this pattern (having real variables).

The eigenvalues (canonical correlations) of the first two roots are highest and we have to interpret that

they contribute most to total variance explanation. However, this does not mean that they explain most of total

variance. In canonical regression analysis the measure how much of total variance a root explains is called re-

dundancy. Redundancy is computed over the sum of all squared factor loadings using z-normalized variables.

The redundancies of the predicant roots of our example are low (0.07 and 0.08). It means that only 7 to 8% of

the variance in the set of dependent variables is redundant (is explained by the predictor set). Nevertheless, our

canonical correlation coefficient is 0.82 and is highly significant (p = 0.004). However, again I used only sim-

ple linear random numbers to generate the data matrix. Canonical regression gives very quickly highly sig-

nificant results. The reason is that we use even more pairwise correlations than in other multivariate methods.

The canonical correlation coefficient but is always larger than the largest pairwise correlation coefficient.

Hence, with a manifold of variables in both sets it is very easy to get to highly significant canonical correlations

from nothing. It is therefore important to use Bonferroni corrected experiment wise error rates. Accept only

canonical correlations at α < 0.05 / n where n is the total number of variables in the matrix.

Canonical regression analysis depends more than other multivariate techniques on our interpretation.

This is surely the reason why it is relatively seldom used in the natural sciences. It is a technique designed for

the social sciences where model interpretation is more important.

10.1 Advices for using canonical regression analysis

• Canonical regression analysis is—similar to ordinary regression analysis — based on sets of linear re-

gressions. The basic prerequisites of the method are therefore similar to those of multiple regression. It

can be seen as a generalization of all regression techniques.

• The predicator variables have to be metrically scaled.

• The sample should contain at least twice the total number of variables.

• Canonical regression analysis makes only sense if you deal in both data sets with at least three vari-

ables. If you have less variables perform ordinary regression.

• High levels of multicollinearity should be avoided. Leave out redundant variables.

• It is difficult to assess whether results of a canonical regression analysis are stable. If your data set is

large you might again subdivide it at random and use one part for verification. Another technique is

bootstrapping.

• Use always Bonferroni corrected error levels.

Page 92: Statistical advices for biologists

92 Statistical advices

11. Discriminant analysis

Discriminant analysis is of major importance in the social sciences. In biology it is slightly neglected

although it was introduced by the genetic Sir Ronald Fisher (in 1936) and might have broad application. In dis-

criminant analysis we compare simultaneously groups of a dependent variable with sets of independent vari-

ables. Our aim is to cluster the independent variables in such a way that we can answer two basic questions:

Are there significant differences between the groups of the dependent variable? How can these differences be

explained. Additionally, discriminant analysis allows us to place an object of unknown group membership into

a certain group.

Ordinary discriminant analysis deals with predefined groups of a dependent variable and groups

them according to a set of predictor variables. This is the major difference between this technique and clus-

ter or factor analysis where groups are defined during analysis. These techniques are therefore complementary

and can be used in parallel. Discriminant analysis is particularly important in taxonomy for classifying material

of unknown species identity into taxonomic groups.

As other multivariate techniques discriminant analysis is based on the general linear model. It assumes

therefore that predictor and dependent variables are linearly related. The main approach is similar to regression

analysis. A discriminant function, or root, has the general form

(11.1)

In matrix notation

Hence for each group of the grouping (dependent) variable Y the discriminant analysis reduces the n

predictor variables via a regression analysis to one variable Y. The next step is then the use of a predefined

metric to define the distances and the variances between the groups of the dependent variable. In effect dis-

criminate analysis is an analysis of variance based on values defined by a principal component analysis. It is a

combination and extension of both methods.

Consider the example of

raw data given in the Table

below. We have a grouping

variable in which three

groups have been distin-

guished. Our aim is to find

out whether these groups

can be defined in terms of

six predictor variables. The

first step is the computation

of the discriminant func-

tion. If your dependent

variable is already ordinary

0 1 1 2 2 01

...n

n n i iY a a X a X a X a a X= = + + + = + ∑

Y X a= •

Grouping variable A 0.40579 0.270201 0.658187 0.537873 0.839663 0.514065 A 0.754831 0.233816 0.395176 0.781711 0.370998 0.256507 A 0.038035 0.968032 0.06392 0.08297 0.740034 0.166025 A 0.047228 0.209852 0.550758 0.203171 0.577028 0.468727 A 0.85061 0.167219 0.533852 0.290431 0.22524 0.016191 B 0.029823 0.203699 0.586644 0.33116 0.760493 0.123904 B 0.313258 0.227969 0.313263 0.051667 0.520589 0.196067 B 0.054548 0.245398 0.008269 0.13598 0.12819 0.401658 B 0.37051 0.327885 0.246795 0.237902 0.186019 0.213754 B 0.085525 0.060634 0.412615 0.082217 0.480254 0.231014 B 0.097939 0.071351 0.836022 0.099824 0.177903 0.21942 C 0.596642 0.857957 0.374789 0.853542 0.143245 0.865735 C 0.983964 0.297421 0.77297 0.677762 0.635495 0.85314 C 0.556686 0.56247 0.663161 0.778506 0.97705 0.781346 C 0.976894 0.642783 0.952449 0.819444 0.399631 0.981602 C 0.125528 0.38791 0.123148 0.858056 0.05197 0.280876 C 0.355885 0.743428 0.663563 0.660941 0.424318 0.831978

Predictors

Page 93: Statistical advices for biologists

Statistical advices 93

scaled this function can be estimated directly. Otherwise it is advisable to undertake first a cluster analysis to

define possible groups. What we need is a discriminant criterion. This criterion tries to define the discrimi-

nant function to mirror maximum distances between the group means defined by the predictor vari-

ables. Remember that we can divide total variance of a data matrix into parts of within group variance and be-

tween group variance. This is the same as to discriminate between explained (between group) and unexplained

(within group) variance. As in an analysis of variance our discriminant criterion is the quotient of between and

within group variance (SS = sums of squares).

(11.2)

Where B and W are the dispersion matrices containing the respective-

sums of squares and V is the respective eigenvector. The optimal solu-

tion for the discriminant function is found when Γ becomes a maxi-

mum γ. To solve this problem we use matrix notation. We have Y=X•a.

We have to maximize SSbetween = (Y-X•a)2. Hence

X’•X gives the covariance matrix. It’s eigenvalue is therefore a measure of the variance explained by the func-

tion. To solve eq. 11.2 we rearrange

(11.3)

There is not a single discriminant function. Each function explains only a part of the whole variance.

This part is measured by the discriminant factor (the eigenvalue) defined by the loadings of each predictor

variable (similar to factor analysis). The part of variance explained by a function ui is simply defined by the

quotient γu through the sum of γ-values. If the dependent variable consists of n groups n-1 discriminant func-

tions (called roots) exist. To define which of the discriminant functions are statistically significant a coefficient

is used that is called Wilk’s lambda. This is defined by

(11.4)

By transforming Wilk’s lambda to χ2 we can test the significance of the remaining g-k-1 eigenvalues after ac-

cepting k prior ones.

(11.5)

where n is the number of cases, m the number of predictors and g the number of groups. The test has (m-k)(g-

k-1) degrees of freedom.

The result of our example

shows the Table beside.

Wilks’ lambda is an in-

'• •Γ = =

• •between

within

SS U B USS U W U

1dSS 2X' (Y X a) 2X' Y 2X' X a 0 a (X' X) X' Yda

−= • − • = • − • • = → = • • •

1(W B I) U 0− • −λ • =

1

11

n

ik i k

Lγ= +

=+∏

2 m g(n 1 ) ln L2+

χ = − − −

Standardized variable loadings Root 1 Root 2 VAR2 -1.16981 -0.64115 VAR3 -0.70646 0.245368 VAR4 -0.21681 0.579723 VAR5 -0.07326 0.453765 VAR6 0.021754 -0.0245 VAR7 -0.99706 -0.96171 Eigenvalue 9.444256 0.568714 cum. R2 0.943202 1

Chi2 test of roots

Eigen-value

Canonical R

Wilk's lambda CHI2 df p

1 9.444256 0.950922 0.061035 32.15754 12 0.001314 2 0.568714 0.602109 0.637465 5.177945 5 0.394573

Page 94: Statistical advices for biologists

94 Statistical advices

verse measure with smaller values indicating higher signifi-

cance. We see that only the first root is statistically significant.

It explains 94% of total variance.

The next step of a discriminant analysis is the formulation of a

classification function. The classification function looks simi-

lar to the discriminant function and is in the simplest case di-

rectly derived from the discriminant function.

However many other algorithms for deriving classification functions have been proposed. Best known

are the generalized distance functions (based on the Mahanalobis distance) and non-parametric classification.

Statistical packages give the a-values of this function as shown beside. On the basis of this function we

get a value for each element of the grouping variable. But wee need something that tells us which group this

function predicts. This provides us the probability concept that is based on Bayes theorem of dependent prob-

ability. The probability that an element i belongs to group m is defined by

The equation points therefore with probability p to a certain group. The sum of all probabilities adds to one.

For instance a new element X has for each variable the following values: 0.15, 0.57, 0.51, 0.89, 0.61, 0.83.

We get probabilities as given in the next Table.

X belongs with probability p = 0.76 to A, with probability 0.0002 to B, and with probability 0.24 to C. Proba-

bly, the new element belongs to group A. The possibility that a certain object does not belong to any group is

excluded. This has to be considered when classifying new objects with a classification function of a discrimi-

nant analysis.

0, 1, 1, 2, 2, , , 0, , ,1

...n

i i i i i i n i n i i k i k ik

Y a a X a X a X a a X=

= + + + + = +∑

,

,

1

( , )k m

Yi m

nY

k

ep i me

=

=

Classification function A B C X X(A) X(B) X(C) p=.29412 p=.35294 p=.35294 VAR2 36.93971 16.61794 46.31781 0.15 5.5409565 2.492691 6.947672 VAR3 22.61406 10.16465 36.09058 0.57 12.8900142 5.793851 20.57163 VAR4 8.098105 8.250122 14.48112 0.51 4.13003355 4.207562 7.385371 VAR5 -4.01284 -1.88237 1.059242 0.89 -3.5714276 -1.67531 0.942725 VAR6 -1.02588 -0.85007 -1.42232 0.61 -0.6257868 -0.51854 -0.86762 VAR7 42.14875 17.56869 49.03653 0.83 34.9834625 14.58201 40.70032 Constant -27.404 -7.43788 -50.9016 -27.404 -7.43788 -50.9016 Exp() 1.84932E+11 37670371 5.77E+10 Sum 2.43E+11 p(A) 0.762076 p(B) 0.000155 p(C) 0.237769 Sum 1

Classification function A B C p=.29412 p=.35294 p=.35294 VAR2 36.93971 16.61794 46.31781 VAR3 22.61406 10.16465 36.09058 VAR4 8.098105 8.250122 14.48112 VAR5 -4.01284 -1.88237 1.059242 VAR6 -1.02588 -0.85007 -1.42232 VAR7 42.14875 17.56869 49.03653 Constant -27.404 -7.43788 -50.9016

Page 95: Statistical advices for biologists

Statistical advices 95

11.1 Advices for using discriminant analysis:

• Discriminant analysis is—similar to regression analysis— based on sets of linear regressions. The basic

prerequisites of the method are therefore similar to those of multiple regression.

• The predictor variables have to be metrically scaled

• In cases of strong deviations from linearity log-transformed variables should be used.

• Make sure that no element of the sample belongs to more than one group. Hence, your model must as-

sure that all variables can be grouped unequivocally.

• The sample should contain at least twice the number of variable used for discrimination.

• The number of grouping variables should always be larger than the number of groups.

• Discriminant ability depends on the metrics chosen and on the grouping algorithm. If the independent

variables are not or only slightly correlated a step wise procedure should be used. In this case the statis-

tic package filters step by step those variables that best discriminate between the groups. At high levels

of multicollinearity a simultaneous grouping should be preferred.

• Check your results graphically. In this case use only the first two discriminant functions.

• Use only the significant discriminate functions for interpretation.

Page 96: Statistical advices for biologists

96 Statistical advices

12. Multidimensional scaling Multidimensional scaling (MDS) is not a single statistical technique. It stands for a family of techniques

designed for the analysis of hidden structures in the data set. MDS can be seen as an alternative to factor analy-

sis. It is appropriate if we want to explain observed similarities or dissimilarities between objects (variables).

MDS techniques try to find meaningful underlying dimensions along which our variables can be placed in such

a way that their distances to these dimensions become minimal. Our task is then to interpret these dimensions

in terms of the variables nearest to them. This is similar to factor analysis but while factor analysis deals exclu-

sively with correlation matrices MDS may analyze any kind of similarity or dissimilarity matrix.

MDS can be viewed as a way of rearranging objects in an efficient manner to arrive in a configuration

that best approximates observed distances in a predefined n-dimensional space (Fig. 12.1). To do this we need

an algorithm that tells us when a certain configuration in space gives minimal distances to the number of prede-

fined axes. This algorithm provides a measure of the goodness of fit and is commonly termed stress. Stress is

an inverse measure. The lower its value is, the better fits our configuration of axes to the data matrix. The most

common measure of stress is the PHI-value defined by

where d stands for the distances after rear-

rangement in the predefined n-dimensional

space and δ stands for the observed dis-

tances. Hence MDS uses least squares to

find the best solution. The equation deals

with distances or proximities. We can use

any appropriate measure of proximity.

Most statistical packages use the general

Minkowski concept with z = 2, hence they

apply Euclidean distances.

The first problem of MDS is the initial definition of the number of dimensions, hence the number of

hidden variables we have to deal with and to interpret. The higher the number of dimensions is, the better will

(in general) be the fit of our MDS model. If we define as many dimensions as we have variables in the data

matrix, the fit would be perfect. But then we get no more information. The aim of MDS is of course to reduce

the number of variables that have to be interpreted (the

complexity). The problem of choosing the right num-

ber of dimensions is therefore similar to factor analy-

sis. A common technique to decide how many dimen-

sions are appropriate is the Scree test. We plot the

final stress values against different numbers of dimen-

sions. The right number of dimensions should be at

2

2

( )( )ij ij

ij

dP H I

dδ⎡ ⎤−

= ⎢ ⎥⎢ ⎥⎣ ⎦

∑ ∑∑ ∑ Define the number of

dimensions and determine theinitial coordinates of objects

Calculate distances

Calculate stressRearrange the space

Terminate

PHI(t)-PHI(t-1) > ε PHI(t)-PHI(t-1) < ε

00.05

0.10.15

0.20.25

0.30.35

0.4

0 1 2 3 4 5 6

Dimensions

Fina

l stre

ss

Fig. 12.1

Fig. 12.2

Page 97: Statistical advices for biologists

Statistical advices 97

the point where such a plot levels off at the right side. Fig12.2 indicates a three dimensional solution. Another

important criterion is the clarity of the solution. If the data points in the final plot forma an unstructured cloud

the number of dimensions might be inappropriate to produce an interpretable solution. In this case we should

try other spaces.

Most statistical packages do not use raw data for

analysis but need distance matrices. An example

gives the Table above. Statistica needs a specific

distance matrix containing first all pairwise dis-

tances (in this case pairwise correlations). Addi-

tionally you have to give means and standard de-

viations for each variable, the number of cases

(they have to be identical for each variable) and the

type of distance matrix. In our case the one stands

for a correlation matrix. After rearrangement Statis-

tica gives the final configuration with distances of

all variables to the predefined axes. The next step is a plot as in Fig. 12.3. These scatterplots visualize the dis-

tances of all variables to the axes. Our task is then to interpret them. Fig. A shows a scatterplot of the first two

dimensions from a three dimensional solution. B shows the same in the case of a four dimensional solution

(data of the correlation matrix above). Note that dimension numbers are arbitrarily. Dimension 1 in A is not the

same as dimension 1 in B. It seems that B is better interpretable than A while separating variables B, C, D, and

A B C D E F G H I J A 1.00 -0.28 0.12 -0.66 0.52 -0.30 0.64 -0.29 0.37 0.56 B -0.28 1.00 0.21 0.03 -0.29 -0.60 -0.62 0.36 -0.16 0.24 C 0.12 0.21 1.00 -0.08 -0.43 -0.79 -0.29 0.12 -0.34 0.14 D -0.66 0.03 -0.08 1.00 -0.31 0.27 -0.51 0.43 -0.02 -0.33 E 0.52 -0.29 -0.43 -0.31 1.00 0.19 0.21 0.19 0.00 0.29 F -0.30 -0.60 -0.79 0.27 0.19 1.00 0.34 -0.22 0.13 -0.38 G 0.64 -0.62 -0.29 -0.51 0.21 0.34 1.00 -0.60 0.47 0.22 H -0.29 0.36 0.12 0.43 0.19 -0.22 -0.60 1.00 -0.27 -0.16 I 0.37 -0.16 -0.34 -0.02 0.00 0.13 0.47 -0.27 1.00 -0.13 J 0.56 0.24 0.14 -0.33 0.29 -0.38 0.22 -0.16 -0.13 1.00 Means 0.68 0.74 0.55 0.37 0.45 0.39 0.40 0.45 0.38 0.51 St.Dev. 0.27 0.15 0.36 0.27 0.33 0.36 0.34 0.32 0.26 0.30 No.Cases 10 Matrix 1

Final configuration (MDS.sta) D*: Raw stress = ,0517626; Distance = ,0227499 D^: Raw stress = ,0206787; Stress = ,0143801 Dim1 Dim 2 Dim 3 Dim 4 A -0.67929 -0.53947 -0.15523 -0.08208 B 0.782599 -0.42462 -0.0376 0.579336 C 0.610582 -0.66704 -0.28422 -0.57932 D 0.833877 0.652524 -0.3977 -0.13709 E -0.52181 0.188644 0.76067 0.062249 F -0.22941 1.033405 -0.00373 -0.21983 G -0.9108 0.027484 -0.3137 -0.26931 H 0.653011 0.174123 0.686223 -0.11797 I -0.30796 0.348221 -0.42256 0.660701 J -0.2308 -0.79327 0.16785 0.103316

EI

GA J

CB

H

DF

-1-0.8-0.6-0.4-0.2

00.20.40.60.8

11.2

-1.5 -1 -0.5 0 0.5 1 1.5

Dimension 1

Dim

ensi

on 2

E IG

AJ C

B

H

DF

-1

-0.5

0

0.5

1

1.5

-1 -0.5 0 0.5 1

Dimension 1

Dim

ensi

on 2

A B

Fig. 12.3

Page 98: Statistical advices for biologists

98 Statistical advices

H more clearly. In A variables I, E, A, and G seem to cluster together, a view that is not supported by the four

dimensional solution. But be careful. Again, the original data matrix contained simple random numbers. Scat-

terplots but tempt us to see patterns even when there is nothing. This pattern seeking mentality makes MDS a

dangerous technique when applied to data without thorough prior model building.

At last we have to interpret our dimensions. This is a problem similar to factor analysis. Interpretation

has to be done according to the variables lying very near to or very far from the focal dimension.

Statistica performs a classical metric MDS. In this case data are quantitative and proximities

(correlation coefficients or other measures of distance) are treated directly as distances. In many cases it is ap-

propriate to transform data prior to analysis. We might use log-transformed or standardized data, or we might

performed a weighted MDS where variables are given weights prior to analysis.

Often, our data are not of the metric type. They might represent classes like ‘yes’ or ‘no’ or group mem-

berships like ‘A’, ‘B’, ‘C’ etc. In this case we might perform non-metric MDS, an option that provide some

statistic packages like PC Ord or CANOCO.

Non-metric MDS is based on ranked distances

and tends to linearize relations. It iteratively

searches for rankings and placements of n enti-

ties in k dimensions. Optimal solutions are

found by comparing the stress values of the

data matrix with those of randomized matrices.

Randomization means that the data from the

main matrix are reshuffled within columns.

PC Ord reads raw data matrices formatted as

shown above. You have to give the numbers of

plots and variables and information whether

the variables are of a metric (Q) or a categorical type (C). The example contains three metric and two categori-

cal variables that characterize 10 species. I used the Soerensen measure of distance and an initial number of

4 dimensions. The first step of the analysis is a test which number of dimensions is appropriate. In non-metric

MDS this is done via a Monte Carlo test using randomized data matrices. In our example a one dimensional

solution is proposed because it is the lowest dimensional solution with a minimum number of randomized data

STRESS IN RELATION TO DIMENSIONALITY (Number of axes) Stress in real data Stress in randomized data

15 runs Monte Carlo test 30 runs

Axes Minimum Mean Maximum Minimum Mean Maximum p

1 7.193 25.421 50.895 11.557 40.702 51.607 0.0323 2 3.082 6.714 26.443 2.031 8.135 28.931 0.1613 3 0.377 3.252 20.956 0.28 1.364 2.972 0.0645 4 0.001 1.17 14.569 0.018 0.434 1.747 0.0323

p = proportion of randomized runs with stress < or = observed stress i.e., p = (1 + no. permutations <= observed)/(1 + no. permutations)

Page 99: Statistical advices for biologists

Statistical advices 99

12.1 Advices for using multidimensional scaling:

• Multidimensional scaling provides a visual representation of complex relationships. It doesn’t give any

significance values for observed patterns. Hence be careful when interpreting the patterns.

• Measurement uncertainties might have a high influence on MDS results. Use only data with low stan-

dard errors.

• Axe numbers are arbitrarily. Hence the first axis is not more important than others. This is a difference

to factor analysis.

• Metric MDS relies on data sets with normal distributed errors. If you aren’t sure whether this prerequi-

site is met transform the data (by ranking or by logarithmization) or use non-metric MDS.

• The larger the number of dimensions is, the more difficult becomes the interpretation. If two or three

dimensional solutions still have high stress values abandon MDS and try factor or cluster analysis.

• Use the Scree test to establish the right number of dimensions. A rule of thumb is that stress values

above 0.15 (or above 15 when transformed to a range between 0 and 100) are unacceptable, stress val-

ues below 0.1 (below 10) are very good.

• For interpreting an MDS plot concentrate on the large scale structures. The stress function accentuates

(while using squared distances) discrepancies in larger distances and the algorithm tries hard to get

them right. Small scale structures are difficult to interpret and might simply arise due to distortions of

the distances caused by non-zero stress.

• For analysis structures inside perceived clusters you may extract the variables forming the clusters and

rerun the MDS (so-called local MDS).

• Compare the MDS results (if possible) with those from a factor analysis. This helps interpreting clusters

and dimensions.

sets having a lower stress value than the observed

data.

At last the program computes the ordination

scores for each species. This results in the follow-

ing one-dimensional plot (Fig. 12.4). We detect

three fairly good separated clusters. But look at the

initial data. You don’t need any MDS to detect the

same picture. Four of the five variables point to

this clustering and the interpretation of the dimen-

sion is clear. Differences in the species are manifest in each of the variables measured. Hence, they do not

really measure different things.

Non-metric MDS might also be applied in detecting the ‘right’ number of factors (dimensions) in a

factor analysis. The randomization algorithm provides a clear criterion for choosing the number of factors in a

subsequent factor analysis.

-2-1.5

-1-0.5

00.5

11.5

2

0 2 4 6 8 10 12

Species number

Ord

inat

ion

scor

es

Fig. 12.4

Page 100: Statistical advices for biologists

100 Statistical advices

13. Bootstrapping and jackknifing Jackknife and bootstrap are general techniques to answer the question how precise estimates are. Both

techniques find application when it is impossible to give standard deviations and standard errors from distribu-

tion parameters of the whole population. The basic idea behind both techniques is to use the sample as a surro-

gate of the population and to estimate standard errors from series of subsamples from this sample.

Assume we have five abundance data from a population of birds. This is our single sample. From these

five data points we can estimate the mean abundance of the birds. But we have no estimate how precise we

estimated mean abun-

dances. We lack an esti-

mate of the standard error.

We use the jackknife pro-

cedure and take subsam-

ples from these five data

point. This is shown in the table above. The original sample is given in bold. It predicts a mean abundance of

11.6 individuals. Now we take five subsamples each time leaving out one data point. We get new mean values.

And we need so-called pseudovalues p. These pseudovalues are computed from

(13.1)

where n is the number of subsamples. The jackknife estimate of the standard error is then the standard error of

the pseudovalues

(13.2)

In our case SE is 4.15. Jackknifing is an especially useful technique for esti-

mating error terms of index values like diversity or similarity metrics.

Jackknife estimates must not be used to compute confidence intervals.

Therefore you can’t test hypothesis. You can’t use t– or U-tests for compar-

ing means. The great advantage of the jackknife is its ease in use.

More complicated but more precise in estimating distributions is the boot-

strap technique that was developed from the jackknife. The general principle

is shown in Fig. 13.1. To derive distribution parameters a manifold of subsam-

ples is taken from the single samples. These subsamples serve to approximate

the unknown distribution of the population.

Although the principle of the bootstrap technique looks simple the details are

quite complicated. First of all the sample has to reflect the total population.

Important for the outcome is the way the subsamples are taken. The number

of elements can vary at random. In this case many small samples will occur

that might give rise to higher standard errors. You can also take subamples of

( 1)( )i ip X n X X= − − −

2( )( 1)

ip pSE

n n−

=−

Mean p 10 15 11 8 14 11.6 10 15 11 8 11 9.2

15 11 8 14 12 13.2 10 11 8 14 10.75 8.2 10 15 8 14 11.75 12.2 10 15 11 14 12.5 15.2

Standard error 4.15

Abundance data

Population

Sample

1000 bootstrap samples

1000 bootstrapparameter estimates

Bootstrap distribution

Distribution parametersas estimates of

population distribution

Fig. 13.1

Page 101: Statistical advices for biologists

Statistical advices 101

normalized sizes.

The next table shows a simple example. We have ten abundance data from a species and intend to estimate the

degree of aggregation. For this we use the Lloyd index of mean crowding given by

(13.3)

We can estimate L from the ten data points. However, this is a simple number. We do not know how

precise our estimate is. We need a standard error and confidence limits. We take ten subsamples of different

size and compute L for each subsample. The mean of these estimates gives us the bootstrap estimate of L and

the standard deviation is our desired estimate of the standard deviation of the sample estimate. The standard

error is given by SD / √10 = 0.019.

Greater problems arise if we want to compute confidence limits. In the simplest case we might assume a

normal distribution of bootstrap values around the true sample mean. In this case the standard error would be

calculated as usual

2

21 1sLxx

= − +

Abun-dance data Sample Subsamples

8.151521 8.1515213 8.151521 8.151521 8.151521 8.151521 8.151521 8.151521 8.151521 8.20434 8.2043398 8.20434 8.20434 8.20434 8.20434 6.934291 6.9342914 6.934291 6.934291 6.934291 6.934291 6.934291 6.934291 3.789047 3.789047 3.789047 3.789047 3.789047 4.347014 4.3470144 4.347014 4.347014 4.347014 4.347014 4.347014 4.347014 4.142075 4.1420753 4.142075 4.142075 4.142075 4.142075 4.142075 1.43515 1.43515 1.43515 1.43515 1.43515 1.43515 6.718321 6.718321 6.718321 6.718321 6.718321 2.748634 2.748634 2.748634 2.748634 2.748634 6.447198 6.447198 6.447198 6.447198 6.447198 6.447198 6.447198 6.447198 6.447198

Mean 5.291759 6.3558485 5.814463 4.479801 5.635089 5.553563 5.149881 5.725732 7.291134 4.937582 4.923843 Variance 5.393642 3.9780408 8.43979 3.752072 6.049019 6.540019 6.108753 4.657389 0.685472 3.940115 3.009485

Lloyd 1.003638 0.9411387 1.077654 0.963738 1.013035 1.031984 1.036155 0.967413 0.875741 0.959086 0.921039

0.9786984

Standard deviation 0.0607208

Bootstrap estimate of Lloyd index

00.010.020.030.040.050.060.070.080.09

-3 -2.6 -2.2 -1.8 -1.4 -1 -0.6 -0.2 0.2 0.6 1 1.4 1.8 2.2 2.6 3

Studentized parameter value

Freq

uenc

y

2.5 percentile 97.5 percentileFig. 13.2

Page 102: Statistical advices for biologists

102 Statistical advices

(13.4)

In many cases however, bootstrap distributions are not normal but skewed. In these cases we might use

studentized bootstrap values. We use a large number of subsamples (for instance 999) and compute for each

(13.5)

where n is the size of the subsample i and si its standard deviation. Now we plot the frequency distribution of

these bi values as shown in Fig. 13.2. If we rank all bi values from smallest to largest we get the 95% confi-

dence limits from the 2.5 and 97.5 percentile values. We need the 25th and the 975th bi values and use these

values instead of cα. In the example of the Figure above these values are 1.8 and 2.4. Hence

The values differ from the 1.96 value of the 95% confidence limit of a normal distribution.

A key assumption behind the bootstrap and the jackknife is that the original sample values were inde-

pendent. If this is not the case (for instance if the data are correlated) things become more complicated. For

correlated data a shifting block sample procedure has bee proposed where not random samples but many data

blocks are used to retain at least part of the correlation.

For estimating standard errors via the bootstrap at least 1000 subsamples should be taken. For having

not too much replicates (samples that contain the same elements) the original sample size should not be smaller

than 30. For small sample sizes below 10 bootstrap estimates become more and more unreliable. In these cases

we should enlarge our confidence limits and reduce type 1 error probabilities to 1% or even 0.1%.

SDCL x cnα= ±

ii

i

x xb ns−

=

97.5 2.5( ; ) ( 2.4 ; 1.8 )percentile percentiles s s sCL x b x b x xn n n n

= + − = + −

Page 103: Statistical advices for biologists

Statistical advices 103

13.1 Reshuffling methods Closely related to bootstrapping are methods that infer statistical significance from a random reshuffling

of data. Consider the coefficient of correlation. Statistical significance of r > 0 (H1) is tested against the null

hypothesis H0 of r = 0. Most statistics programs do this using Fisher’s Z-transformation

(13.1)

that is approximately normally distributed and has a variance of σ2 = 1/(n-3). For instance a coefficient of cor-

relation of r = 0.60 obtained from 10 data points has Z = 0.69. σ = 0.38. Hence –2σ = −0.76 < Z < 2σ = 0.76

and we conclude that at the 5% error level r is not significantly different from 0.

We can test in a different way and use a reshuffling method. The table above shows the necessary calcu-

lations. X and Y are correlated by r = 0.6. Now we reshuffle Y 10 times (in reality at least 100 reshufflings

would be necessary for a good estimate of the standard deviation sr of r. For simple inference of statistical sig-

nificance however in most cases even 50 reshufflings are sufficient. If we estimate sr sufficiently precisely we

can use the Z-transformation (not Fisher’s Z) and compare Z with the standard normal distribution. For our 10

reshuffles this comparison points to a significant difference at p < 0.05.

Another way is to use a t-test

Note that the standard error of a distribution is identical to the standard deviation of the sample. You

have to run the t-test with 1 degree of freedom. We get p = 0.13 n.s.. We see that each of the three methods

gives a different level of significance. Each test has a different power and uses a different approximation to the

standard normal.

Another example. The following Excel table contains two variables X and Y. We wish to compare the

means. A t-test is problematic because both distributions are highly skewed. The alternative, an U-test might be

influenced by the high number of tied ranks. The t-test points to a significant difference at p < 0.05. Again we

use a reshuffling of data. We compare the mean significance level of (in theory 1000) randomizations) with the

observed one. In this case we can do this without programming using a very good Excel add in, PopTools that

1 1 rZ ln2 1 r

+⎛ ⎞= ⎜ ⎟−⎝ ⎠

0.6t 2.310.26

= =

X Y X Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 0.04 -0.24 0.04 0.14 0.14 0.81 1.00 0.81 0.81 0.71 0.21 -0.24 0.05 0.35 0.81 0.35 0.77 0.21 0.05 0.14 -0.01 0.05 0.05 1.00 0.71 0.14 0.51 0.05 0.51 0.05 0.81 0.21 0.77 1.00 1.00 0.14 -0.24 0.21 -0.24 0.22 0.14 0.22 0.21 0.43 1.00 0.81 0.05 0.21 -0.24 0.71 0.77 1.00 0.59 0.71 0.59 -0.24 0.71 0.71 0.43 -0.24 -0.01 0.81 0.81 0.14 -0.01 0.74 0.43 0.74 1.00 0.05 -0.24 0.71 0.77 0.77 1.00 0.77 1.00 0.77 0.60 1.00 0.60 0.43 1.00 0.77 -0.24 0.14 0.71 0.43 0.05 -0.01 0.43 0.63 0.77 0.63 0.71 0.77 -0.01 0.05 0.21 0.43 -0.01 0.43 0.05 0.21 0.65 0.21 0.65 -0.01 -0.01 0.43 0.21 0.43 -0.24 0.77 -0.01 0.43 0.71 0.26 -0.01 0.26 0.81 -0.24 0.14 -0.01 0.71 0.14 0.21 0.14 0.81 0.81

r 0.60 0.09 0.32 -0.45 -0.37 -0.14 -0.04 0.37 0.00 0.09 0.00 Mean r -0.01 StDev 0.26 0.69 Z 2.34

Page 104: Statistical advices for biologists

104 Statistical advices

is freely available at www.cse.csiro.au/

poptools. This add in contains many

advanced level matrix applications and

statistical tests. One module contains a

Monte Carlo simulation. Monte Carlo

simulations provide us wish resampling

procedures with desired confidence lim-

its. In our example 500 resamplings with

replacement of the data (using the Pop-

Tools module shuffle) gives a mean sig-

nificance level of 0.67 with a lower con-

fidence limit (at p < 0.01) of 0.03. We

infer that there are no differences in the

mean of both variables because the ob-

served significance level is still within

the confidence limit range. But look at

the t-test. From a mean of 0.67 and a

standard deviation of s = √0.06 = 0.24

we would infer a significant difference

of the observed and the reshuffled significance levels (Z = [0.67 - 0.05] / 0.24 = 2.58; p = 0.01). The reason is

that the skew in our data biases the type I error level of the parametric test that assumes a normal random distri-

bution of errors around the mean. Indeed, the upper 95% confidence limit of r = 0.67 + 2*0.24 = 1.15 is already

impossible to achieve. Such skews are quite frequent in biological data and if we are unsure about the data

structure a Monte Carlo approach is desirable.

A third example shows how to infer regularities. Assume 20 species of a genus occur within a given

habitat. Classical ecological theory tells that species to co-occur must differ to a certain degree to minimize

interspecific competition. We want to test this assumption. We have data on species body weights. Our ques-

tion is whether species body weights are regularly spaced within the observed range. The aim is to compare the

observed variance with the variance expected if body sizes were randomly distributed along the body weight

axis. Hence we rank our data according to body size and calculate the variance of the distances in body weight.

This variance would be minimal at an equal spacing of body weight. The more species body sizes are aggre-

gated (clumped) the higher the variance should be.

The next table shows how to perform the test. Our raw data are first ranked. The next step is to compute

the quotients q = Wn / Wn-1 for all consecutive species pairs. Hence, we use an equal spacing at a log scale (ln

[q] = ln[Wn] - ln[Wn-1]). This is our test variable. If species weight were regularly spaced the variance of q sq

would be low. Now we test this value against an appropriate null model. We fix the upper and lower values of

body weight and assign S - 2 body weights at random within this range. From 1000 or more such randomiza-

tions we infer each time sq and get also the standard error of sq. From this we obtain upper and lower 95% con-

fidence limits. If the observed sq value is within this range we conclude a random distribution of body size. In

the previous table I show only 4 such randomizations and use the Z-transformation. This procedure is valid

Page 105: Statistical advices for biologists

Statistical advices 105

Spe-cies

Body weights

Ranked body weights Wi/Wi-1 Radomized body weights Ranked randomizations Wi/Wi-1

1.00 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 0.97 2.00 9.90 1.02 1.05 4.00 4.33 8.70 4.56 1.01 1.78 1.20 1.02 1.05 1.84 1.24 1.05 3.00 1.02 1.76 1.73 4.57 7.12 4.36 3.50 1.69 2.31 2.69 1.26 1.67 1.30 2.24 1.24 4.00 8.31 2.13 1.21 5.08 6.77 8.51 6.12 2.35 3.25 3.48 1.37 1.39 1.41 1.29 1.08 5.00 8.93 2.35 1.10 1.01 3.76 8.67 5.51 2.48 3.76 4.36 1.83 1.05 1.16 1.25 1.33 6.00 3.90 2.86 1.22 2.35 1.78 6.36 1.26 4.00 4.33 4.74 1.94 1.61 1.15 1.09 1.06 7.00 4.44 3.15 1.10 9.14 4.95 1.20 8.00 4.11 4.52 5.54 2.04 1.03 1.05 1.17 1.05 8.00 7.73 3.87 1.23 7.53 3.25 4.74 1.83 4.57 4.70 6.36 2.59 1.11 1.04 1.15 1.27 9.00 2.86 3.90 1.01 4.87 2.31 9.64 4.18 4.59 4.95 6.80 3.50 1.00 1.05 1.07 1.35 10.00 8.11 3.98 1.02 5.64 9.80 7.11 2.59 4.87 5.55 7.01 4.18 1.06 1.12 1.03 1.19 11.00 2.35 4.38 1.10 5.05 8.99 8.15 8.44 4.87 6.14 7.11 4.37 1.00 1.11 1.02 1.05 12.00 2.13 4.44 1.01 7.55 7.10 8.95 2.04 5.05 6.34 7.62 4.48 1.04 1.03 1.07 1.02 13.00 3.98 6.11 1.38 8.53 4.52 2.69 1.37 5.08 6.35 8.15 4.56 1.01 1.00 1.07 1.02 14.00 6.11 7.06 1.16 2.48 4.70 6.80 1.02 5.64 6.77 8.51 5.51 1.11 1.07 1.04 1.21 15.00 8.38 7.73 1.09 9.14 6.14 7.01 4.37 7.53 7.10 8.67 6.12 1.33 1.05 1.02 1.11 16.00 4.38 8.11 1.05 4.11 9.72 7.62 1.94 7.55 7.12 8.70 7.35 1.00 1.00 1.00 1.20 17.00 7.06 8.31 1.02 4.87 6.35 9.02 8.29 8.53 8.99 8.95 8.00 1.13 1.26 1.03 1.09 18.00 3.87 8.38 1.01 1.69 6.34 3.48 7.35 9.14 9.72 9.02 8.29 1.07 1.08 1.01 1.04 19.00 3.15 8.93 1.07 4.59 5.55 5.54 4.48 9.14 9.80 9.64 8.44 1.00 1.01 1.07 1.02 20.00 1.76 9.90 1.11 9.90 9.90 9.90 9.90 9.90 9.90 9.90 9.90 1.08 1.01 1.03 1.17

Variance 0.03 0.04 0.04 0.08 0.01 Mean 0.04

Stan-dard

devia- 0.03 Z -0.49

Species Body length

Ranked length

Wn-Wn-1 Randomized Wn-Wn-1

1 5 3 3 3 3 3 3 3

2 23 5 2 4.61602 3.33436 4.73984 5.52019 3.34387 6.56478 1.61602 0.33436 1.73984 2.52019 0.34387 3.56478

3 22 5 0 7.84749 4.27741 4.92115 6.90281 4.27264 8.30225 3.23148 0.94306 0.18131 1.38261 0.92877 1.73747

4 20 5 0 8.67062 4.34326 5.26870 7.80111 7.35484 8.37788 0.82313 0.06584 0.34755 0.89830 3.08220 0.07562

5 5 6 1 10.22749 4.73583 7.67317 8.42719 7.49316 9.09417 1.55687 0.39257 2.40447 0.62609 0.13832 0.71630

6 3 6 0 10.93195 7.70894 8.24709 10.70102 8.55679 9.18830 0.70446 2.97311 0.57392 2.27383 1.06363 0.09413

7 7 7 1 11.40584 8.09563 8.61787 10.86658 10.01747 10.67631 0.47389 0.38669 0.37078 0.16556 1.46068 1.48801

8 7 7 0 12.41842 10.32518 9.08945 11.92101 10.99051 11.69942 1.01258 2.22955 0.47159 1.05443 0.97303 1.02311

9 10 7 0 12.68992 11.73564 10.02200 12.18558 13.15817 12.00595 0.27150 1.41046 0.93255 0.26457 2.16766 0.30652

10 10 7 0 12.92895 12.33975 11.86065 13.89549 14.65210 12.27325 0.23903 0.60411 1.83865 1.70991 1.49393 0.26730

11 14 10 3 13.26682 13.89517 16.68878 14.46294 16.29927 12.57782 0.33787 1.55542 4.82813 0.56745 1.64717 0.30457

12 15 10 0 13.70206 14.19615 17.06035 17.64220 16.90208 12.60405 0.43525 0.30098 0.37157 3.17926 0.60281 0.02623

13 10 10 0 14.77200 14.80155 17.65808 18.13831 18.11138 13.24600 1.06994 0.60540 0.59774 0.49611 1.20930 0.64195

14 7 14 4 18.53647 15.65097 18.05398 18.40808 19.84745 15.37377 3.76447 0.84942 0.39589 0.26978 1.73606 2.12777

15 7 15 1 19.33640 18.73682 18.79762 19.03405 20.64275 18.80901 0.79993 3.08585 0.74364 0.62597 0.79531 3.43524

16 6 19 4 19.97707 18.88592 18.88550 19.46045 20.69299 19.30537 0.64067 0.14910 0.08788 0.42639 0.05024 0.49636

17 5 20 1 20.81931 19.62716 18.94299 20.03710 21.14846 20.01186 0.84224 0.74124 0.05749 0.57666 0.45547 0.70649

18 6 21 1 22.52915 20.28602 20.43533 20.96781 22.27172 20.51961 1.70983 0.65887 1.49234 0.93071 1.12326 0.50775

19 21 22 1 22.79907 22.42710 20.52134 22.97860 22.53772 21.87933 0.26992 2.14108 0.08601 2.01079 0.26599 1.35972

20 19 23 1 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 0.20093 0.57290 2.47866 0.02140 0.46228 1.12067

Variance 1.719 0.96643 0.85887 1.43079 0.79319 0.58506 1.08721

Mean 0.95359

Z 2.654 StdDev 0.28853

Page 106: Statistical advices for biologists

106 Statistical advices

under the assumption of a normal random distribution of errors around the mean. Z = -0.49 indicates a random

distribution of body weights.

The next example shows an often made error with this resampling approach. 20 ground beetle body

length were measured in mm and the approach is the same as before. Because we used lengths instead of

weights we use q = Wn-Wn-1 instead of Wn/Wn-1. Now we randomize and get Z = 2.65. The observed vari-

ance is higher than the randomized and we infer a significant aggregated distribution of body sizes. The error in

this example is that we measured length in mm but calculated our random numbers at five decimals. Hence our

observed q values take only natural numbers. The randomized q values take all real numbers between 3 and 23.

They are less clumped and this small difference produced our significant result. Indeed, the table above shows

the same calculations using randomized data at the mm level. Now our significant result vanishes. Indeed the

original data were nothing more than random

numbers.

The error occurred not only due to the

difference in precision. The observed q values

were small natural numbers with a lot of tied

ranks (identical values). Such data are always

prone to Poisson errors.

Good programs that do resamplings or

reshufflings are PopTools, Sample, or Resam-

pling procedures. Of course R and MatLab allow

for an easy programming of own algorithms.

Spe-cies

Beak length

Ranked length

Wn-Wn-1 Randomized Wn-Wn-1

1 5 3 3 3 3 3 3 3 2 23 5 2 3 3 4 3 3 4 0 0 1 0 0 1 3 22 5 0 4 3 4 3 3 4 1 0 0 0 0 0 4 20 5 0 5 3 5 3 3 7 1 0 1 0 0 3 5 5 6 1 8 4 5 4 4 7 3 1 0 1 1 0 6 3 6 0 8 5 7 4 5 8 0 1 2 0 1 1 7 7 7 1 10 6 7 6 5 8 2 1 0 2 0 0 8 7 7 0 10 7 11 8 10 10 0 1 4 2 5 2 9 10 7 0 11 8 12 8 13 11 1 1 1 0 3 1 10 10 7 0 13 9 13 10 13 14 2 1 1 2 0 3 11 14 10 3 13 13 15 12 14 15 0 4 2 2 1 1 12 15 10 0 13 15 17 15 14 15 0 2 2 3 0 0 13 10 10 0 14 15 17 17 15 16 1 0 0 2 1 1 14 7 14 4 14 16 17 18 18 17 0 1 0 1 3 1 15 7 15 1 14 17 18 19 18 17 0 1 1 1 0 0 16 6 19 4 14 17 20 19 19 19 0 0 2 0 1 2 17 5 20 1 17 19 20 20 21 20 3 2 0 1 2 1 18 6 21 1 22 19 21 22 22 21 5 0 1 2 1 1 19 21 22 1 22 19 22 22 22 22 0 0 1 0 0 1 20 19 23 1 23 23 23 23 23 23 1 4 1 1 1 1 Variance 1.719 1.94 1.50 1.05 0.94 1.83 0.83 Mean 1.35 Z 0.78 StdDev 0.47

Page 107: Statistical advices for biologists

Statistical advices 107

13.2 Mantel test and Moran’s I

The Mantel test (after the America biostatistician Nathan Mantel) is a test of spatial autocorrelation.

Assume an guild of ground dwelling species. We measured species composition at different sites. We have the

suspicion that he change in species composition is related to changes in soil type. We also measured several

variables of soil chemistry and soil type. Now we have two matrices. One of sites and species occurrences and

one of sites and soil property. The question is whether these two matrices are correlated. Hence, apart from a

simple correlation between species richness and soil type we wish to include the spatial aspect. In order to do

so we first construct two distance matrices containing the site distances of species composition and soil type.

The next step is to calculate the coefficient of correlation between the two matrices. The procedure is shown in

the next table. We use the two distance matrices. For convenience these contain normalized (Z-transformed)

data. The Mantel test statistic is now the cross product term (the coefficient of correlation)

(13.2.1)

where n is the number of elements in the lower part (or upper) of the distance matrix = m(m-1)/2 with m sites.

In the example below the r-values is the sum of all xy products of the elements x and y of both lower parts of

the distance matrices.

The elements of the distance matrices are not independent. Therefore it is not possible to test for signifi-

cance directly. We test therefore via a permutation procedure and reshuffled the elements of one of the table

randomly. At least 5000 such reshuffles are

then used to compute mean coefficients and

its confidence limits. For site numbers lar-

ger than 30 r might be tested directly using

Fisher’s Z-transformation.

Of course the Mantel test can also be used

to test for simple spatial autocorrelation. In

this case the second matrix contains only

the (Z-transformed) distances of the sites.

An alternative is to rank the matrix entries

prior to computing r. This procedure is

equivalent to Spearman’s rank order corre-

lation. It should be used in cases when X

and Y are non-linearly related.

Another often used statistic in spatial analy-

sis is Moran’s I. Moran’s I is similar to a

correlation coefficient all applied to pair-

wise cells of a spatial matrix. It differs by

weighting the covariance to account for

n n

ij iji 1 j 1

1r Z(1) Z(2)n 1 = =

=− ∑∑

Species distances Sites

Sites 1 2 3 4 5 6 7 8 9 10 1 1 1.586 -1.72 0.253 0.465 1.118 0.475 0.63 1.307 0.695 2 1.586 1 0.023 0.443 -0.45 -0.5 1.096 -0.63 0.604 -0.59 3 -1.72 0.023 1 -1.4 0.303 1.745 0.131 -0.56 0.638 -0.82 4 0.253 0.443 -1.4 1 -0.71 0.546 0.557 0.079 0.173 0.169 5 0.465 -0.45 0.303 -0.71 1 -0.46 0.562 1.314 -0.44 -0.45 6 1.118 -0.5 1.745 0.546 -0.46 1 0.579 0.103 0.221 -0.48 7 0.475 1.096 0.131 0.557 0.562 0.579 1 0.264 0.766 1.004 8 0.63 -0.63 -0.56 0.079 1.314 0.103 0.264 1 -0.17 1.202 9 1.307 0.604 0.638 0.173 -0.44 0.221 0.766 -0.17 1 1.143 10 0.695 -0.59 -0.82 0.169 -0.45 -0.48 1.004 1.202 1.143 1 Soil type distances Sites

Sites 1 2 3 4 5 6 7 8 9 10 1 1 -0.16 -0.93 -0.24 -0.57 0.202 -0.15 0.039 0.711 -0.43 2 -0.16 1 -0.29 1.139 -0.55 1.098 0.955 -2.33 -1.3 -0.53 3 -0.93 -0.29 1 -0.32 -0.4 1.2 2.141 -1.35 0.09 -0.48 4 -0.24 1.139 -0.32 1 -0.05 -2.22 2.106 -0.3 -0.14 -1.78 5 -0.57 -0.55 -0.4 -0.05 1 -0.46 0.611 0.575 -0.35 -0.54 6 0.202 1.098 1.2 -2.22 -0.46 1 -0.32 1.13 0.224 0.629 7 -0.15 0.955 2.141 2.106 0.611 -0.32 1 0.333 -1.24 0.056 8 0.039 -2.33 -1.35 -0.3 0.575 1.13 0.333 1 -0.23 0.422 9 0.711 -1.3 0.09 -0.14 -0.35 0.224 -1.24 -0.23 1 0.074 10 -0.43 -0.53 -0.48 -1.78 -0.54 0.629 0.056 0.422 0.074 1

r species x soil 0.201

Page 108: Statistical advices for biologists

108 Statistical advices

spatial non-independence of cells with respect to distance. The measure is defined by

(13.2.2)

where N is the number of matrix cells, and z the Z-transformed ell values and w the weighing coefficient w is

frequently defined as

(13.2.3)

d is the difference between the cells i an j. w is therefore an inverse distance function. Nearer cell have there-

fore more influence on Moran’s I than cells spatially apart.

Statistic programs frequently calculate the statistical significance of I from a reshuffling of cells (a

Monte Carlo approach). If cell values were randomly distributed (not spatially autocorrelated) the expected I is

(13.2.4)

The statistical significance of the difference of I - E0(I) can be a estimated from the variance of I under

the assumption that the distribution of values is linearly random. The variance of I is then

N N

ij i ji 1 j 1

N N N2i

i1 1i j 1

w z zNI

zwij=

= =

= =

=∑∑

∑∑ ∑

ij 2ij

1w(1 d )

=+

01E (I)

N 1−

=−

2 2 2 22 1 2 0 1 2 0

3 2 20

N[(N 3N 3)S NS 3S ] b[(N N)S 2NS 6S ] 1(N 1) S (N 1)

σ − + − + − − − += −

− −

N N2

1i 1 j 1

2N N N

2i 1 i 1 j 1

N N4 4

i ii 1 i 1

2 2N N2 2

i ii 1 i 1

1S (wij wji)2

1S wij wji2

N (x ) N zK

(x ) z

= =

= = =

= =

= =

= +

⎛ ⎞= +⎜ ⎟

⎝ ⎠

− μ= =

⎛ ⎞ ⎛ ⎞− μ⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

∑∑

∑ ∑ ∑

∑ ∑

∑ ∑

Page 109: Statistical advices for biologists

Statistical advices 109

14. Markov chains

Beside equation solving matrices have by far more biological applications. Assume you are studying a

contagious disease. You identified as small group of 4 persons infected by the disease. These 4 persons con-

tacted in a given time another group of 5 persons. The latter 5 persons had contact with other persons, say with

6, and so on. How fast does the disease spread in the population? To answer this question we first define a ma-

trix describing the first contacts. You have four infected persons and 5 contact persons of the second group.

Hence person 1 of the first group contacted with person 2 of the second group. No. 2 of the first group

contacted with No. 1, 2, and 4 of the second group and so on. Now you describe the second order contacts of

group three with group two.

To find the number of persons in group three that had (via group two) contact with infected persons of

group one you have to multiply both matrices. We get as the result

How to interpret this result? From the computational scheme of a dot product of two matrices follows

that the new elements of C result from all combinations of respective rows and columns of A and C. Hence the

ones and twos denote indirect contacts of a person in the third group with a person of the first group. Person 1

of the third group had 6 indirect contacts (1+1+2+2), the

persons 2 and 4 only one.

However, we can also use probabilities of infection

instead of contacts. Say that any contact gives a probabil-

ity of 0.3 that a person will be infected. We have to re-

place the one with 0.3 to get the probability that persons in

contact with infected persons get infected. Our model be-

comes

0 1 0 01 1 1 00 0 1 10 1 0 00 0 0 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟=⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

A

0 1 1 0 10 0 0 0 11 1 0 0 11 0 0 0 00 1 1 0 01 1 0 0 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟

= ⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

B

1 1 2 20 0 0 11 2 1 10 1 0 01 1 2 11 2 1 1

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟

= • = ⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

C B A

Page 110: Statistical advices for biologists

110 Statistical advices

Hence person 1 of the third group has a probability of 0.54 of being infected. Of course this method can

be applied to further groups or generations (if we interpret the groups as generations). By this we get probabili-

ties of occurrences of initial events in subsequent time windows. The matrix multiplication allows for the pre-

diction of infections during epidemics.

Markov chains The above discussion leads immediately to the concept of Markov

chains (after the Russian mathematician Andrei Markov, 1856-1922). A

Markov chain is a sequences of random variables in which the future variable

is determined by the present variable but is independent of the way in which the

present state arose from its predecessors. Hence if we have a series of process

states the value of state n is determined by only two things. The value of state

n-1 and by a rule that tells how state n-1 might transform into state n. Most

often these rules contain probabilities. Then state n-1 goes with probability pi into any state i of n. Hence in a

Markov chain states prior than the previous do not influence the future fate of the chain. This is why Markov

chains are often said to be without memory.

Take for instance a gene that has three alleles A, B, and C. These can mutate into each other with prob-

abilities that are given in Fig. 14.1. A mutates into B with probability 0.12 and into C with probability 0.2.

Hence with probability 1 - 0.12 - 0.2 = 0.68 nothing hap-

pens. We can these so-called transition probabilities

write in a matrix form.

This matrix that gives the transition probabilities is called the transition matrix. The sum of all matrix

rows must add to 1, the sum of all probabilities. This is a general feature of all probability (stochastic) matri-

ces. If we now take the initial allele frequencies we can compute the frequencies of the alleles in the next gen-

eration. Assume we have initial frequencies of A = 0.2, B = 0.5, and C = 0.3. This gives a vector of the form X0

= {0.2, 0.5, 0.3}. The frequencies in the next generation are computed from

Again, the new frequencies of A = 0.201, B = 0.429, and C = 0.37 add up to zero. If we multiply two

probability matrices the resulting matrix is again a probability matrix.

0.09 0.09 0.18 0.180 0 0 0.09

0.09 0.18 0.09 0.090 0.09 0 0

0.09 0.09 0.18 0.090.09 0.18 0.09 0.09

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟

= • = ⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

C B A

0.68 0.07 0.10.12 0.78 0.050.2 0.15 0.85

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

P

1 0

0.68 0.07 0.1 0.2 0.2010.12 0.78 0.05 0.5 0.4290.2 0.15 0.85 0.3 0.37

⎛ ⎞⎛ ⎞ ⎛ ⎞⎜ ⎟⎜ ⎟ ⎜ ⎟= • = =⎜ ⎟⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠⎝ ⎠ ⎝ ⎠

X P X

A B

C

0.10.2

0.050.15

0.07

0.12

Fig. 14.1

Page 111: Statistical advices for biologists

Statistical advices 111

If we continue the process we get X3=PX2,

X4=PX3… In general the frequencies of a Markov

chain after n states starting from the initial condi-

tions X0 and determined by the transition matrix P

is given by

(14.1)

Of cause this law is very similar to recursive

processes leading to exponential distributions. It is

a generalization. Equation 14.1 defines the simplest

form of a Markov chain process.

We also see that state n+1 is only dependent

on state n. This property serves even as the general

definition of a Markov process. The probability i of

a state Xn with respect to the previous states X1 to Xn-1 is the same as the probability of Xn with respect to state

Xn-1 only. The previous states have no influence any more. Mathematically written

(14.2)

Does our mutation process above reach in stable allele frequencies or do they change forever? This

question can be answered twofold.

Does the frequency distribution re-

mains constant or does the process

eliminate one or more alleles? The

first question is whether the frequen-

cies of the alleles remain constant. In

this case the following condition

must hold

This can be written in terms of eigen-

vectors

(14.3)

Pn is called the stationary state. This state is defined

by the eigenvector U of the transition matrix P with

the largest eigenvalue. This is scaled to λ = 1. Xn is

called the steady-state or equilibrium vector. The

Excel example beside shows the transition matrix of

three alleles. λ3 = 1 and the third eigenvector U3 de-

fines the stationary state, that is the frequency distribu-

10 0

−= • = •Λ • •n nnX P X U U X

n n 1 n 2 n 3 n 1 n n 1p(X i | X ,X ,X ...X ) p(X i | X )− − − − −= = =

1 •+ = =n n nX X P X

n n nP X 1X (P 1I) X 0• = → − • =

0

0.1

0.2

0.3

0.4

0.5

0.6

0 2 4 6 8 10 12 14

Steps

Freq

uenc

y

Stationary frequenciesdefined by the eigenvector

Fig. 14.2

Page 112: Statistical advices for biologists

112 Statistical advices

tion the process will end in. Note that the eigenvectors are nor-

malized to have the length one. To get the frequencies

(probabilities) we have to divide U3 through the sum of it’s val-

ues. Fig. 14.2 shows that in our case the allele frequencies

quickly converge to the steady state.

Do all Markov chains converge? We look at several im-

portant special cases. Fig. 14.3 shows a graphical representation

of a Markov chain with four states. Given are the transition

probabilities. The missing probabilities can be inferred from the

scheme. We see that state D cannot be reached from any other

state. It forms a closed part of the whole chain. If a chain does

not contain closed subsystems it is called irreducible. In such a

system all states can be reached. Fig.

14.4 now shows a simple example of

a periodic chain. The whole chain

forms a circle. Fig. 14.3 shows an

aperiodic chain. Fig. 14.3 shows

also two other important concept.

First the states A, B, and C are recurrent that means it is sure that that a finite time (even a very long time) the

process returns to the initial state. State D is not recurrent. In some chains there is only a certain probability that

the chain returns to a previous state. These chains are called transient. There is no way back to D. An impor-

tant class of finite Markov chains are now recurrent and aperiodic chains. These are called ergodic. The chain

of Fig. 14.3 is ergodic (except of state D), chain of Fig. 14.4 not (it is periodic). The next table shows the tran-

sition matrices, the eigenvalues, and the eigenvectors of both chains. For both chains λ = 1 exists, but only

chain 14.3 converges. The probability matrix theorem now tells that every irreducible ergodic transition ma-

trix (that is the matrix containing only probabilities) has a steady state vector T to which the process converges.

(14.4)

This steady state vector is defined by the eigenvector of the matrix. Hence for ergodic matrices (these

are by far the most important) eq. 14.3 has always a solution. The theorem also implies that every transition

matrix has an eigenvector λ = 1.

Now look at the following matrix

It defines a transition matrix. Once state B or state D is reached the probability of change to B and D is 1.

These states cannot be left. The matrix has two absorbing states. In general a transition matrix has as many

absorbing states as it has ones on its diagonal.

Fig. 14.2 points also to another problem. How fast do Markov processes converge to the steady state.

kk 0lim P X T→ ∞ =

0.5 0 0.2 00.2 1 0.4 00.2 0 0.1 00.1 0 0.3 1

⎛ ⎞⎜ ⎟⎜ ⎟=⎜ ⎟⎜ ⎟⎝ ⎠

P

A

BD

C

0.3

0.9

0.6

0.3

0.4

0.1

Fig. 14.3

Fig. 14.4

A B C

0.6

0.8 0.7A B C D Eigenvalues Eigenvector 4

A 0 0.3 0.3 0 -0.3 0.384111B 0.4 0.7 0 0 0.1 0.512148C 0.6 0 0.7 0.9 0.7 0.768221D 0 0 0 0.1 1 0

A B C Complex eigenvalues Eigenvector 3A 0.2 0 0.6 -0.05 0.597913 0B 0.8 0.3 0 -0.05 -0.597913 0C 0 0.7 0.4 1 0 0

Page 113: Statistical advices for biologists

Statistical advices 113

The time to convergence is obviously connected to the probabilities in the matrix. The recurrence time of a

state i is now defined as the mean time at which the process returns to i. It can be shown that the recurrence

times T of any state i are inversely related to the stationary probabilities π.

(14.5)

The mean time to stay in any state is of course the inverse of the

probability not to leave the state. Hence in Fig. 14.3 the recur-

rence time of state A is T = (0.38+0.51+0.77)/0.38) = 4.33 steps.

The question how long it will take to reach the stationary state is

identical to the question what function describes the Fig. 14.3 and

how to calculate the parameter values of the function. With some

mathematics one can show that it is an exponential function of

the type

(14.6)

There are no simple solutions for the parameters.

A typical application of Markov chains in biology is succession.

For instance gravel pits have a distinct mosaic plant community

structure. Abandoned pits go through series of successional

stages. If we now map the plant distribution of the gravel pit im-

mediately after abandonment we get a matrix of initial states.

From other studies it is known with what frequency certain struc-

tural elements transform into others. Hence we have a transition

matrix. We can now describe the whole process of succession by

a Markov chain model. In this case we have a matrix of the initial

stage and the transition matrix. The model looks as follows

(14.7)

We consider six different plant community classes and have the

following transition matrix. Our

initial stage is given by Fig. 14.6

where the six communities are rep-

resented by different colours. After

t = 100 states (Fig. 14.7) our map

changed totally. Community types 1

and 2 dominate, 5 and 6 vanished.

After even 1000 states (Fig. 14.8)

not much had changed. However,

very slowly the frequency of com-

munity 3 raises. The proportion of

ii

1T =π

btp ae −=

0= •ttX P XA B C D E F

1 4 2 1 1 1 32 3 1 1 3 2 23 3 3 1 1 3 14 3 3 2 4 2 25 1 1 3 2 2 36 2 3 2 4 3 37 1 2 3 1 3 48 1 2 3 1 3 4

A B C D E F1 1 2 4 1 6 42 1 1 2 1 6 43 4 3 1 2 6 54 4 3 1 4 5 55 4 2 4 5 5 46 6 2 3 5 4 37 5 1 3 6 4 48 3 1 2 6 5 2

A B C D E F1 3 2 3 3 4 22 2 1 2 4 3 33 2 2 3 1 3 14 3 4 1 2 2 35 2 1 1 3 2 16 2 3 2 1 2 37 4 1 1 2 1 38 2 3 2 1 3 2

do while(jj.le.runs) do 100 i=1,arkol do 101 j=1,arnu ran1=ran(iseed) k=area(i,j) prob1=0 do 102 ii=1,spec prob1=prob(ii,k)+prob1 if(ran1.le.prob1)then area(i,j)=ii goto 101 endif 102 continue 101 continue 100 continue

Fig. 14.5, Photo Jan Meyer

1 2 3 4 5 61 0.12 0.20 0.21 0.29 0.18 0.062 0.26 0.02 0.31 0.03 0.31 0.033 0.05 0.05 0.08 0.12 0.28 0.284 0.09 0.29 0.03 0.26 0.02 0.165 0.26 0.22 0.27 0.21 0.08 0.226 0.21 0.22 0.09 0.09 0.13 0.25

Sum 1.00 1.00 1.00 1.00 1.00 1.00

Fig. 14.6

Fig. 14.8

Fig. 14.7

Page 114: Statistical advices for biologists

114 Statistical advices

community 4 remains stable but type 2, which dominated the intermediate stage of succession, decreases.

How to compute these pictures. Either you apply a commercial program that computes Monte Carlo

simulations and Markov chains or you write a program for your own. In our case I used a self written program

that iterates equation 14.2. For shorter series you can run a math program iteratively. Above a simple Fortran

solution is shown with which I computed the matrices on the left side.

Markov chains find application in probability theory. Assume for instance you have a virus with N

strains. Assume further that at each generation a strain mutates to another strain with probabilities ai→j. The

probability to stay is therefore 1-Σai→j. What is the probability that the virus is after k generations the same as

at the beginning. This can be modelled by a Markov chain with the following transition matrix

We get the desired probability from the matrix element p11 of Pk. Hence

The next table shows the respective Excel solution for a given transition matrix using the Matrix add in

for k =5. The requested probability is pii 0.23. Markov chains are therefore ideal tools for calculating probabili-

ties if we have multiple pathways to reach certain states. Particularly, they describe the probability to get in k

steps from state A to state B if the transition probabilities can be described using a transition matrix.

Random walk models A special example of Markov chains are random walks

Wee know already that random walks are defined by the general state equation

The state Nt is only defined by the previous state and a probability function of change. Typical examples

of such random walks are for instance animal movements. Let’s consider an animal A being at place x0. In a

next step it might turn to left with probability pl, turn to right with probability pr or walk straight on with prob-

ability ps. Our random walk model looks at follows

i 1,1 1N

N1 1,i 1

1 a ap

a 1 a

⎛ ⎞−⎜ ⎟= ⎜ ⎟⎜ ⎟−⎝ ⎠

k k 1P U U−= • λ •

1t tN N ran+ = +

P A B C Eigenvalues EigenvectorsA 0.5 0.05 0.3 0.338197 0.814984 0.550947 0.368878B 0.3 0.8 0.1 0.561803 -0.450512 -0.797338 0.794506C 0.2 0.15 0.6 1 -0.364472 0.246391 0.482379

k = 5 Lk Inverse0.004424 0 0 0.878092 0.264583 -1.107265

0 0.055966 0 0.109323 -0.798204 1.2310890 0 1 0.607621 0.607621 0.607621

PN A B C ULk ULkU-1

A 0.230675 0.20048 0.258105 0.003606 0.030834 0.368878 0.230675 0.20048 0.258105B 0.47613 0.51785 0.43003 -0.001993 -0.044624 0.794506 0.47613 0.51785 0.43003C 0.293195 0.28167 0.311865 -0.001613 0.013789 0.482379 0.293195 0.28167 0.311865

Page 115: Statistical advices for biologists

Statistical advices 115

This is a recursive equation that describes a direc-

tional process. It’s two dimensional equivalent would

have the form

where the columns define forward or backward walk.

Recursive probability functions are also special cases of Markov chains. We can’t know, where the

animals ends his walk. But we might use a model of 5000 animals and try to give probabilities of the outcome.

Such a Monte Carlo simulation provides us with a frequency distribution of end points of the random walk.

Then we can tell that a typical animal ends his walk there or there. To model this we need the possible area into

our animal can walk, the number of possible states. This is indicated by the green area in Fig. 14.9. If this num-

ber is finite we speak of a bounded random walk. What is if the animal reaches the lower or upper boundary?

In the Figure the animal is reflected from the barrier.

1

l

n n s

r

px x p

p−

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

11 12

1 21 22

31 32

⎛ ⎞⎜ ⎟= ⎜ ⎟⎜ ⎟⎝ ⎠

n n

p px x p p

p p

pl

pr

ps

Fig. 14.9

Page 116: Statistical advices for biologists

116 Statistical advices

15. Time series analysis

This last lecture deals with the analysis of biological time series. Such time series can be changes in

population sizes of bacteria, animals, or plants in time,

biological rhythms like the circadian rhythm, patterns of

brain activity in time, or diversity patterns during evolu-

tion. Fig. 15.1 shows a hypothetical time series, the

change of abundance of a species in time. Such a time

series can be described by four basic parameters. The

mean abundance (μ= 14.6), the standard deviation (σ2 =

4.7), and the upper and lower boundaries. The lower

boundary of such an abundance time series is of course 0,

the upper boundary is often not defined. A first important measure of variability in time series is the coefficient

of variation. Because the standard deviation still depends on the mean (σ2∝ μz) CV is defined as σ / μ and is

therefore a standardized measure of variability. In our case CV = √4.7 / 14.6 = 0.32.

A general description of such a time series is

(15.1)

This is a very general recursive function. b is some random variate. If the time delay τ is zero, the next genera-

tion depends solely on the state of the previous. Let’s study eq. 15.1 in more detail. In the simplest case f(N) =

N. Hence

This is a random walk and a typical time series looks as in Fig. 15.1. b is often defined as b = ran(-c,c).

The coefficient of variation of such a random walk has typically values between 0 and 1. The higher N0 is in

relation to the range of b, the lower CV will be.

A time series might also arise from a multiplicative process

where a is typically defined as a = ran (1-c, 1+c). The multiplicative process leads frequently to a higher vari-

ability with CV-values around or above 1. Of course the multiplicative random walk can be transformed into an

additive one by taking the logarithms of abundance N (Fig. 15.2).

If a is small with respect to N the variability will be small,

a large factor a results instead in a large variability that

appears to be chaotic. In chapter 7 of part A we saw that a

proportional rescaling process has the form

This is a power function. We can apply this equation to the

analysis of time series. Fig. 15.3 shows such series. A time

1 ( )t tN f N bτ+ −= +

1t tN N b+ = +

1t tN aN+ =

1ln( ) ln( ) ln( )t tN N a+ = +

2 zaσ μ=

0

5

10

15

20

25

0 10 20 30Time

Abu

ndan

ce

0

50

100

150

200

250

0 10 20 30Time

Abu

ndan

ce

Fig. 15.1

Fig. 15.2

Page 117: Statistical advices for biologists

Statistical advices 117

series can be seen as a complex wave that consists of

many composite waves of different wavelengths (and fre-

quencies). It has therefore much in common with self-

similar processes that are also described by power func-

tions. We apply a ruler length technique. We assume that

this time series was formed by a superposition of waves.

We now lay series of time windows onto this se-

ries and measure for each window length (ruler length) l

the difference ΔN. ΔN is the difference between the ele-

ment Nt and Nt+l. For each windows length l we measure μ

ΔN and σ2ΔN. Then we plot variance (often also called

spectral density) against μ. Additionally we plot σ2ΔN

against ruler length l. Variance and ruler length l of the

time series should be connected by an equation equivalent

to Taylor’s power law.

(15.2)

with H being the so-called Hurst exponent. Figs. 15.3

and 15.4 show that variance and mean and variance and

ruler length are both related by power functions. Our ex-

ponent β gives us an impression how irregular our time

series is. β ( Fig. 15.5) is in our case approximately 1 and

we conclude that we deal with a Poisson process.

H is related to the fractal dimension of the curve and is given by H = 2 - D. In our case the fractal di-

mension D of the curve would be H = 0.86/2 = 2 - D → D = 1.57. Calculating a fractal dimension D by this

method is called the second moment technique and is frequently used in the study of time series. Fig. 15.5 is

called the variogram.

Most often only half of the variance is used to estimate H. Now we deal with a semivariogram. We use

again the window technique of Fig. 15.3 and compute

(15.3)

For a fractal wave γ(l) and l (the wavelength considered) and γ(l) and 1/l = f (the frequency considered)

should be related by a power function. The exponent 2H is again related to the fractal dimension by H = 2 - D.

Now look at Fig. 15.6. A periodic process (a time series) is step by step disturbed by irregularities, so

called noise. I used the function

( ) ( sin( ) (cos( ))i i i iN t a t b tψ ψ= +∑

( ) ( )22 2 1/ 1/ HHl l f fββσ ∝ = = =

2

2 1( )

1 1( ) ( )2 2

N

i l ix xl l

Nγ σ

+⎛ ⎞

−⎜ ⎟⎜ ⎟= =⎜ ⎟⎜ ⎟⎝ ⎠

0

2

4

6

8

10

12

0 10 20 30

t

N

A

B

DC

y = 4.87x0.59

R2 = 0.90

0.1

1

10

0.01 0.1 1 10

MeanV

aria

nce

y = 0.86x0.86

R2 = 0.870.1

1

10

1 10 100

Ruler length

Var

ianc

e

Fig. 15.3

Fig. 15.4

Fig. 15.5

Page 118: Statistical advices for biologists

118 Statistical advices

We might think of an audio wave that becomes less and less clear. At the end it looks totally chaotic.

Each time we compute the variogram and determine the Hurst exponent. For a = 0 (2.6 A) the function is

smooth. The slope of the variogram is approximately 2. From this we infer that the fractal dimension of this

time series is D = 1. Of course, it is a smooth line. Our process is similar to the random walk above. This type

of noise is called brown noise (after the Brownian motion in physics that can be described by a random walk

model). Only the long wavelength contribute to the noise. In B to D the influence of the random variate is step

42 2

1( ) (sin( ) ( , )N t i t ran a a= + −∑

-3

-2

-1

0

1

2

3

4

0 200 400 600 800 1000

Time

NA

-6-4-202468

10

0 200 400 600 800 1000

Time

N

D

-1-0.5

00.5

11.5

22.5

33.5

4

0 200 400 600 800 1000

Time

N

C

-0.50

0.51

1.52

2.53

3.5

0 200 400 600 800 1000

Time

N

By = 0.0023x1.006

R2 = 0.9461

0.01

0.1

1

10

1 10 100 1000

Window lengthV

aria

nce

B

y = 4.0716x0.0274

R2 = 0.61091

10

1 10 100 1000

Window length

Var

ianc

e

D

y = 0.0378x0.5379

R2 = 0.9504

0.1

1

10

1 10 100 1000

Window length

Var

ianc

e

C

y = 3E-05x1.8444

R2 = 0.9522

0.00001

0.0001

0.001

0.01

0.1

1

10

1 10 100 1000

Window length

Var

ianc

e

A

Fig. 15.6

Page 119: Statistical advices for biologists

Statistical advices 119

by step enlarged. The Hurst exponents decrease. In B the exponent is approximately 1, hence the fractal dimen-

sion is D = 1.5. In this case variance is a linear function of wavelength. In other words all wavelengths take

proportionally equally part in total variance. The light equivalent is pink and we speak of pink noise (or 1/f

noise). Pink noise reflects linear scale dependence of noise and is often found in nature. In C the exponent de-

creased to appr. 0.5, D = 1.75. The lower wavelengths (higher frequencies) are responsible for a large part of

total variance, but variance increases still with wavelength. This is the case in red light and for β-values be-

tween 0 and 2 we generally speak of red noise. Lastly in D the slope is zero hence D = 2. All wavelengths

(frequencies) contribute equally to total variance. In the light analogy this would be white and we speak of

white noise. Note that even black noise (H = 1.5) exists (try to model this). In rare cases β becomes negative.

We speak of blue noise.

Why is spectral analysis important? Recent investigations in fractal geometry showed that most natural

phenomena show some mix of long term and short term variability. They can be described by (1/f)β power laws

to detect whether long term or short term processes dominate. In biological processes Hurst exponents were

commonly found to range between 0.5 and 1 leading to fractal dimensions of the time series between 1 and 1.5.

This is not white noise and we should be able to detect long term structures in existing time series.

Look at Figs. 15.6 B and C. I did not take all of the data points but only the last six window sizes of the

time series. Too large window sizes don’t see small wavelengths, Too small window sizes pay too much em-

phasis on small scale patterns. The model used to construct the time series had high small scale variation.

Hence the series exhibits at smallest window sizes another pattern than at larger sizes. Such scale inhomoge-

neities (scaling regions) have to be considered in every time series analysis. Nearly all natural series do not

show the same pattern over its entire length (for instant are not constantly fractal, or have different fractal prop-

erties at different scales). The aim of any time series analysis is also to detect such scaling regions were pat-

terns shift. In our case we infer that our time series changes its properties above a wavelength of appr. 20. Be-

low its white noise, above red to pink noise.

y = 0.9982x + 0.0063R2 = 0.9999

-1-0.5

00.5

11.5

22.5

33.5

0 1 2 3 4

Nt

Nt+

1

A

y = 0.9835x + 0.0333R2 = 0.9714

-1-0.5

00.5

11.5

22.5

33.5

-1 0 1 2 3 4

Nt

Nt+

1

B

y = 0.8494x + 0.2817R2 = 0.7218

-1-0.5

00.5

11.5

22.5

33.5

4

-1 0 1 2 3 4

Nt

Nt+

1

Cy = 0.2297x + 1.3521R2 = 0.0529

-1

0

1

2

3

4

5

6

-4 -2 0 2 4 6

Nt

Nt+

1

D

Fig. 15.7

Page 120: Statistical advices for biologists

120 Statistical advices

Now we look back to Fig. 15.6 We plot for the

same four time series Nt against Nt+1. Fig. 15.7 shows

the results and we see that both values are correlated

except for the white noise case. Therefore we can

study time series by an autoregression analysis. In

general we try to find a function of the type

(15.4)

or even more general

(15.5)

Hence autocorrelation depends on the assump-

tion that nearby objects (data points) are more closely

related than distant ones. We try to model our time

series by an algebraic function. Autoregression analy-

sis also tells us whether there are long term regularities

in our data. The above computations are easily done

with Excel. A Statistica solution for the pink noise

data (Fig. 15.6, 7 B) and three time lags τ shows the

next table. The data are highly autocorrelated, the

slope r is nearly identical with the Excel solution.

Another example. Fig. 15.8 shows bird counts

per hour of the monitoring programme for North

American birds between 1957 and 2001 (data from

Santa Cruz bird club organization). Do bird numbers fluctuate at random or are they regulated? In particular

are they regulated by their own abundance? In such a case we speak of density dependence. Our aim is to de-

tect whether high abundances are followed by lower abundances in the next year and whether low abundances

are followed by high abundances in the next year.

In this case abundance itself would be the regulat-

ing agent. To infer this we undertake an autore-

gression analysis. Figure 15.9 shows a plot of Nt+1

against Nt. We detect no significant autocorrela-

tion. But be carefully. Maybe there are larger time

lags and we should better use the general autocor-

relation model of eq. 2.5. In this case we have to

use a statistic program. Statistica computes with

the present data set a model with 5 time lags. None

of the autoregression functions is statistically sig-

nificant. We are not able to detect any density de-

pendent regulation in our bird data set.

t tN aN bτ−= +

1

1

t

t n t ii

N a N b−

−=

= +∑

0

100

200

300

400

500

600

700

1957 1962 1967 1972 1977 1982 1987 1992 1997

Year

Abu

ndan

ce h-1

y = 0.1962x + 199.12R2 = 0.0407

0100200300400500600700

0 200 400 600 800

Nt

Nt+

1

Fig. 15.8

Fig. 15.9

Page 121: Statistical advices for biologists

Statistical advices 121

17. Statistics and the Internet

Here are several useful links to internet pages that contain information about statistics

Handbooks

Hyperstat (large online statistic handbook and glossary): http://www.davidmlane.com/hyperstat/glossary.html

Semantec (online statistics handbook) http://www.itl.nist.gov/div898/handbook/index.htm

Statistica online handbook (the complete Statistica handbook and glossary for download)

http://www.statsoft.com/textbook/stathome.html

StatPrimer (an online statistic handbook by Bud Gerstman) http://www.sjsu.edu/faculty/gerstman/StatPrimer/

Introductory statistics and multivariate statistics (Two very extensive online statistical textbook covering all

sorts of useful techniques with many animations) http://www.psychstat.missouristate.edu/multibook/mlt00.htm;

Statistik für Psychologinnen und Psychologen (a very well designed online script of statistics with many tables

and examples) http://www.psychologie.uni-freiburg.de/signatures/leonhart/skript/

The General Linear Model. You find information at http://www.socialresearchmethods.net/kb/genlin.htm.

Non-parametric tests. Many informations at http://statpages.org/.

Software sites

Statpac (freeware programs for basic calculations) http://www.davidmlane.com/hyperstat/glossary.html

XLStat (statistic module for Excel, free trials) http://www.davidmlane.com/hyperstat/glossary.html

Virtual Library in Statistics (Many links to interesting web pages and programs) http://www.stat.ufl.edu/vlib/

statistics.html

UCLA distribution calculator (very good probability and table calculator for many basic statistical distribu-

tions) http://www.stat.ucla.edu/~dinov/courses_students.dir/Applets.dir/OnlineResources.html.

UCLA statistics calculators (a large collections of basic statistics calculators and tables, easy to use) http://

calculators.stat.ucla.edu/

Neville Hunt’s homepage (if you want to produce statistic tables by yourself, here you find a very good instruc-

tion how to make Excel tables for important statistical distributions) http://www.mis.coventry.ac.uk/~nhunt/

tables.htm

Past. (a very good simple to use statistic package) http://folk.uio.no/ohammer/past/.

PopTools. (a very useful free Excel add in for spatial analysis and more) http://www.cse.csiro.au/poptools/.

Free statistic packages. (a collection of software sites) http://statpages.org/javasta2.html.

SAM (a very good program for spatial analysis) http://www.ecoevol.ufg.br/sam/.

Matrix (a very good matrix algebra add in for excel) http://digilander.libero.it/foxes/index.htm

Libraries

Virtual Library in Statistics (Many links to interesting web pages and programs)

http://www.stat.ufl.edu/vlib/statistics.html

Page 122: Statistical advices for biologists

122 Statistical advices

18. Links to multivariate techniques

GLM: A nice introductory description at http://trochim.human.cornell.edu/kb/genlin.htm

More comprehensive information at http://www.statsoftinc.com/textbook/stglm.html

Analysis of variance: All about at http://faculty.vassar.edu/lowry/vsanova.html and http://

www.statsoftinc.com/textbook/stanman.html

Multiple regression: all about at http://www.statsoftinc.com/textbook/stmulreg.html and http://

www2.chass.ncsu.edu/garson/pa765/regress.htm

A short course at http://cs.gmu.edu/cne

Path analysis: All about at http://luna.cas.usf.edu/~mbrannic/files/regression/Pathan.html

Cluster analysis: All about at http://www.clustan.com/what_is_cluster_analysis.html

A nice introduction at http://149.170.199.144/multivar/hc.htm

Discriminant analysis: All about at http://www.statsoftinc.com/textbook/stdiscan.html and http://

www2.chass.ncsu.edu/garson/pa765/discrim.htm

Look also at http://www.doe-mbi.ucla.edu/~parag/multivar/da.htm

Factor analysis: All about at http://www2.chass.ncsu.edu/garson/pa765/factor.htm and http://

www.statsoftinc.com/textbook/stfacan.html

Look also at http://www.doe-mbi.ucla.edu/~parag/multivar/pca.htm. And http://www-psychology.concordia.ca/

fac/bukowski/psyc732/related%20files/Lecture%208/Lect%208.ppt

Multidimensional scaling: All about at http://www.mathpsyc.uni-bonn.de/doc/delbeke/delbeke.htm and http://

www.statsoftinc.com/textbook/stmulsca.html.

Matrix algebra: Very nice descriptions at http://www.sosmath.com/matrix/matrix.html. Look also at http://

archives.math.utk.edu/topics/linearAlgebra.html.

Page 123: Statistical advices for biologists

Statistical advices 123

19. Some mathematical sites

Libraries

Mathematics Virtual Library (Many links to interesting web pages and programs) http://www.math.fsu.edu/

Science/math.html

Math on the web (Search engine for all sorts of mathematics) http://www.ams.org/mathweb/mi-

mathinfo07.html

The Math Archive (Many links to interesting web pages and programs) http://archives.math.utk.edu/

Eric Weisstein’s Mathematics ( an online mathematics dictionary) http://mathworld.wolfram.com/

The Internet Mathematics library (a large collections of topics for pupils and students, math-beginners) http://

mathforum.org/library/

Mathematic resources (a large compilation of math internet pages) http://www.clifton.k12.nj.us/cliftonhs/

chsmedia/chsmath.html

Software sites

The Windows software collection (public domain and freeware) http://archives.math.utk.edu/

software/.msdos.directory.html (contains many very nice programs)

Derivative calculator (a nice small but quite effective program to computing derivatives) http://cs.jsu.edu/mcis/

faculty/leathrum/Mathlets/derivcalc.html

JAVA Mathlets for Math Explorations (a nice collection of small math programs for everybody) http://

cs.jsu.edu/mcis/faculty/leathrum/Mathlets/

The integrator (a small but effective integration program) http://integrals.wolfram.com/index.jsp.

The MathServ Calculus toolkit (a collection of Math applets for calculus computation) http://

www.math.vanderbilt.edu/~pscrooke/toolkit.shtml.

Modelowanie reczwistości (a nice Polish page with a program collection and many further links) http://

www.wiw.pl/modelowanie/

Maxima. The oldest but very good free ware math program. http://maxima.sourceforge.net/