You are on page 1of 35

ANALYSIS OF VARIANCE

ASSUMPTIONS BEHIND THE ANALYSIS

ASSUMPTIONS BEHIND THE ANALYSIS


1.- INDEPENDENCE

The experimental units should give similar


results when receiving the same treatment
(errors ij are statistically independent)
2.- NORMALITY
3.- VARIANCE HOMOGENEITY

4.- ADDITIVITY

ASSUMPTIONS BEHIND THE ANALYSIS


1.- INDEPENDENCE

Block by sex vs mixed sex 50:50


Block by initial wt vs random initial wt

Block by litter/location/plot/lab
ALTERNATIVE?
Assign and compare treatments
within BLOCKS

INDEPENDENCE EXPERIMENTAL UNITS


Ten hamsters are exposed to a sudden explosion. The
number of heartbeats per minute was registered before
and after the explosion. The results were:
Animal before

after

Animal before

after

70

115

100

178

84

148

110

179

88

176

67

140

110

191

79

161

105

158

10

86

157

Determine if these data provide enough


information to conclude if treatment affected
significantly ( = 0.05) heart rate.

PAIRED SAMPLES
Calculate the difference (X1 X2) by pairs of
values and use a test t to check if it differs
from zero:
SAS proc:
Data explosio;
Input animal before after;
Dif=after-before;
proc means n mean var std stderr t prt;
var before after dif;
proc print;
run;

PAIRED SAMPLES
N Obs

Variable

Mean

Variance

Std Dev

Std Error

10

BEFORE

10

89.90

247.88

15.74

4.98

AFTER

10

160.30

498.23

22.32

7.06

DIF

10

70.40

179.16

13.38

4.23

N Obs

Variable

Prob<|T|

10

BEFORE

18.06

0.001

AFTER

22.71

0.0001

DIF

16.63

0.0001

ASSUMPTIONS BEHIND THE ANALYSIS


1.- INDEPENDENCE
2.- NORMALITY
MEAN populations should be normally
distributed.
3.- VARIANCE HOMOGENEITY
4.- ADDITIVITY

CHEKING MODEL ASUMPTIONS


MODEL START = MILK TIME MILK*TIME /
OUTP= RESSTART;
PROC UNIVARIATE DATA=RESSTART PLOT
NORMAL;
VAR RESID;
SYMBOL VALUE=DOT;
QQPLOT RESID/NORMAL(MU=EST
SIGMA=EST) CFRAME=LIGR PCTLAXIS(GRID
LGRID=35 LABEL='NORMAL PERCENTILES');

CHECKING FOR NORMALITY (VAR GAINPD)

NORMALITY OF VALUES (A) VS RESIDUALS (B)

(Mead y Curnow)

Normality individuals vs means

BINOMIAL DISTRIBUTION

Comparison of proportions.
Values of dependent variables= 0 1.
Illness incidence, fertility, mortality.
Probability of successes out of total
number of observations.
Normal vs. X2 distribution.

SAMPLING DISTRIBUTIONS OF THE NUMBER OF SUCCESSES, r, FROM


INDEPENDENT TRIALS WITH PROBABILITY OF SUCCESS = p FOR EACH TRIAL

NORMAL DISTRIBUTION OF MEANS


FROM A BINOMIAL DISTRIBUTION
When n is high p (r/n) approaches a normal distrib,
especially if p0.50. In these cases the normal distrib
can be used to determine probability levels. In other
cases, the distribution X2 has to be used.
Normal distribution of p(r/n):
Mean = r/n = p
Variance = p(1-p)/n (maximal for p=0.50)

IC95% x 1.96 p 1.96 p(1 p) / n

Binomial distribution:

IC95% ( x

n 1, 0.025

n 1, 0.975

ANALYSIS OF PROPORTIONS:
USING A NORMAL DISTRIBUTION (N>50)
F

NF

%F

FEED 1

80

20

100

80

FEED 2

175

25

200

87.5

TOTAL

255

45

300

85

Calculate the CI of the difference and check if it contains zero


Variance of the difference sd p1 1 p1 / n1 p2 (1 p2 ) / n2
2

p1 0.8 n1 100 p 2 0.875 n 2 200

2
d

0.00215

IC 95% (X1 X 2 ) 1.96 S d (0.875 0.80) 1.96 0.046


0.075 0.090 0.015 0.165
(contains zero NS 5%)

ANALYSIS OF PROPORTIONS USING A X2 DISTRIBUTION


F

NF

%F

FEED 1

80

20

100

80

FEED 2

175

25

200

87.5

TOTAL

255

45

300

85

OBS.

EXP.

DESV.

P1-F

80

85

-5

P1-NF

20

15

+5

P2-F

175

170

+5

P2-NF

25

30

-5

desv / exp distribution X


2

X 2 52 1 / 85 1 / 15 1 / 170 1 / 30 2.94
X 2 (1 d.f.; 5%) 3.84 A 5% of the values in the distribution are 3.84
2.94 3.84 NS at 5%
Hoja excel

BINOMIAL DISTRIBUTION
Degrees of
freedom

50

10

2.5

0.1

0.45

2.71

3.84

5.02

6.64

10.8

1.39

4.61

5.99

7.38

9.21

13.8

2.37

6.25

7.82

9.35

11.3

16.3

3.36

7.78

9.49

11.1

13.3

18.5

4.35

9.24

11.1

12.8

15.1

20.5

5.35

10.6

12.6

14.5

16.8

22.5

6.35

12.0

14.1

16.0

18.5

24.3

7.34

13.4

15.5

17.5

20.1

26.1

8.34

14.7

16.9

19.0

21.7

27.9

10

9.34

16.0

18.3

20.5

23.2

29.6

12

11.3

18.5

21.0

23.3

26.2

32.9

15

14.3

22.3

25.0

27.5

30.6

37.7

20

19.3

28.4

31.4

34.2

37.6

45.3

24

23.3

33.2

36.4

39.4

43.0

51.2

30

29.3

40.3

43.8

47

50.9

59.7

40

39.3

51.8

55.8

59.3

63.7

73.4

60

59.3

74.4

79.1

83.3

88.4

99.6

This table gives the value of x2


for
which
a
particular
percentage P of the chisquared distribution is greater
than x2. These values of x2 are
tabulated for various degrees
of freedom.

SAS ORDERS
Data valor z;
Z=probit (1-/2);run;
Data valor f;
F=finv(1- , gl1, gl2);run;
Data valor t;
t= tinv (1- /2, n-1);
Data valor chi;
Chi=probchi (x2, gl);run;
Proc print;
Run;

ANALYSIS OF PROPORTIONS

2 VS T

Differences of 10 percentage units


n

Prop P1

Prop P2

X2

P X2

P t test

10

0.3

0.4

0.22

0.639

0.66

30

0.1

0.2

1.18

0.278

0.286

30

0.3

0.4

0.66

0.417

0.426

30

0.52

0.6

0.33

0.568

0.578

50

0.1

0.2

1.96

0.161

0.165

50

0.2

0.3

1.33

0.248

0.2526

100

0.2

0.3

2.67

0.102

0.103

100

0.5

0.6

2.02

0.155

0.157

USE OF PROC GENMOD

Pienso
A
A
B
B

destete
21
28
21
28

lechones incidencia
960
42
878
15
780
62
945
25

USE OF PROC GENMOD


Proc genmod;
Class pienso destete;
Model incidencia/lechones= piensodestete
type3 wald;
Lsmeans piensodestete;
Run;

USE OF PROC GENMOD


Procedimiento GENMOD

Informacin del modelo


Conj. datos
WORK.VISAS
Distribucin
Binomial
Funcin de vnculo
Logit
Variable de respuesta (Eventos) incidencia
Variable de respuesta (Pruebas)
lechones
Obs usadas
4
Nmero de eventos
144
Nmero de pruebas
3563

USE OF PROC GENMOD


Anlisis de estimadores de parmetros
Error
Wald 95% Lmites ChiDF Estimacin estndar
de confianza cuadrado Pr > ChiSq

Parmetro
Intercept
pienso
a
pienso
b
destete
21
destete
28
pienso*destete
pienso*destete
pienso*destete
pienso*destete

a
a
b
b

1
1
0
1
0
21
28
21
28

Fuente

-3.6055 0.2027 -4.0028 -3.2082 316.39


<.0001
-0.4469 0.3300 -1.0937
0.2000
1.83
0.1757
0.0000 0.0000 0.0000 0.0000
.
.
1.1562 0.2421
0.6817 1.6307 22.81
<.0001
0.0000 0.0000
0.0000 0.0000
.
.
1 -0.1883 0.3890 -0.9508 0.5741
0.23
0.6283
0
0.0000 0.0000 0.0000 0.0000
.
.
0
0.0000 0.0000 0.0000 0.0000
.
.
0
0.0000 0.0000 0.0000 0.0000
.
.
DF cuadrado Pr > ChiSq

pienso
1
destete
1
pienso*destete 1

7.74
29.81
0.23

0.0054
<.0001
0.6283

USE OF PROC GENMOD


Medias de mnimos cuadrados (lsmeans)

Efecto

Error
Chipienso destete Estimador estndar

pienso
a
pienso
b
destete
destete
pienso*destete
pienso*destete
pienso*destete
pienso*destete

a
a
b
b

21
28
21
28
21
28

-3.5684
-3.0274
-2.7669
-3.8289
-3.0845
-4.0524
-2.4493
-3.6055

0.1523
0.1210
0.1030
0.1650
0.1578
0.2604
0.1324
0.2027

DF cuadrado Pr > ChiSq

1
1
1
1
1
1
1
1

549.32
625.52
721.90
538.44
382.12
242.12
342.39
316.39

<.0001
<.0001
<.0001
<.0001
<.0001
<.0001
<.0001
<.0001

USE OF PROC GENMOD


Logit=transformacin de variable= log [i/(1- i)]

log [i/(1- i)]-trat 1 vs log [i/(1- i)]-trat 2 =1.156

[i/(1- i)]-trat 1
= e1.156 = 3.18

Odd ratio=
[i/(1- i)]-trat 2

MORTALITY AT PARTURITION: USE OF PROC GENMOD

proc glm data=zeug_data;


class treatment pariteit batch;
model pmort = tb bf bf*bf bw pariteit batch treatment /ss1
ss3 solution;
run;
proc genmod data=zeug_data;
class treatment pariteit batch;
model db/tb=tb bf bf*bf bw pariteit batch treatment /
dist=binomial link = logit type3 type1;
run;
logit(P)=log(P/1-P) for Binomial distribution
Chi-square test vs. t-test

MORTALITY AT PARTURITION: USE OF PROC GENMOD VS GLM

Source

glm

genmod

tb
BF
BF*BF
BW
Pariteit
Batch
Treatment

DF

Type I SS

Mean Square

F Value

Pr > F

1
1
1
1
4
3
2

0.11962043
0.01411844
0.02726153
0.03406395
0.01666229
0.01904203
0.00434103

0.11962043
0.01411844
0.02726153
0.03406395
0.00416557
0.00634734
0.00217051

13.10
1.55
2.98
3.73
0.46
0.69
0.24

0.0005
0.2173
0.0878
0.0569
0.7677
0.5577
0.7890

Source

Deviance

DF

ChiSquare

Pr > ChiSq

Intercept
tb
BF
BF*BF
BW
Pariteit
Batch
Treatment

166.0464
146.6630
145.0037
140.2808
134.2984
131.2930
128.8061
127.7296

1
1
1
1
4
3
2

19.38
1.66
4.72
5.98
3.01
2.49
1.08

<.0001
0.1977
0.0298
0.0144
0.5569
0.4777
0.5838

ASSUMPTIONS BEHIND THE ANALYSIS

1.- INDEPENDENCE
2.- NORMALITY
3.- VARIANCE HOMOGENEITY

Variable transformations

4.- ADDITIVITY

VARIANCE HOMOGENEITY within treatments

Treatments affect mean values but should not affect to its variability

CHEKING MODEL ASUMPTIONS


PROC GPLOT DATA=RESSTART;
TITLE1 'RESIDUAL VS PREDICTED START PLOT ';
AXIS2 MINOR=NONE LENGTH=10 CM
LABEL=(ANGLE=90 "RESIDUALS");
AXIS1 MINOR=NONE LENGTH=10 CM
LABEL=("PREDICTED");
PLOT RESID*PRED/HAXIS=AXIS1 VAXIS=AXIS2 VREF=0;
AXIS3 MINOR=NONE LENGTH=10 CM
LABEL=("PERIOD");
RUN;

VARIANCE HETEROGENEITY:
START

FNWT

VARIANCE HOMOGENEITY
Levenes test
Proc glm data=veneer;
class brand;
Model wear=brand;
Means brand/hovtest;
Run;
Source

DF

SUM OF SQUARES

MEAN SQUARE

F VALUE

Pr>F

Model

0.61700000

0.15425000

7.40

0.0017

Error

15

0.31250000

0.02033333

Corrected total

19

0.92950000

R-Square

Coeff Var

Root MSE

Wear Mean

0.663798
Source

6.155120
DF

0.144338
TYPE III SS

2.345000
MEAN SQUARE

F VALUE

Pr>F

0.61700000

0.15425000

7.40

0.0017

brand

Levenes test for homogeneity of wear variance ANOVA of squared deviations from group means
Source
brand
Error

DF
4
15

SUM OF SQUARE
0.000659
0.00466

MEAN SQUARE
0.000165
0.000310

F VALUE
0.93

NS = variance homogeneous

Pr>F
0.7149

CHECKING: Proc means


TREATMENT

MEAN

RANGE

RANGE/MEAN

RANGE/ MEAN

413

223

0.54

11.0

395

123

0.31

6.2

87

102

1.17

10.9

79

70

0.89

7.9

38

71

1.87

11.5

35

59

1.67

10.0

If range values are similar and are not related to meansDO NOT TRANSFORM
If range/means are similarTRANSF. LOGARITHM
If range/means are similarTRANSF. ROOT SQUARE

ADDITIVITY
Treatment effects should be about the same in different blocks,
e.g. insect traps placed in different locations, micro counts

Serie 1
Serie 2
Serie 3

Control
2
10
100

Logarithm scale
Serie 1
Serie 2
Serie 3

Trtmt
4
20
200
Control
0.301
1
2

(Transform multiplicative in additive changes )

Differ.
2
10
100
Trtmt
0.602
1.301
2.301

Differ.
0.301
0.301
0.301

Yij . i . ij log Yij log log i log ij

ADDITIVITY

INSECT COUNTING

UNTRANSFORMED

LOG COUNTS

TRAP TYPE

SITE 1

SITE 2 SITE 3 SITE 1 SITE 2 SITE 3

A
B

11
13

47
62

105
170

1.04
1.11

1.67
1.79

2.02
2.23

15

87

165

1.18

1.94

2.22

43

86

0.85

1.63

1.93

You might also like