Analyse de la variance à un facteur
Michel Tenenhaus
2
Exemple 1 (Snedecor et Cochran)Comparaison de quatre matières grasses
Poids de matière grasse absorbée par fournée de 24 beignets
Matière Grasse
1 2 3 4164172168177156195
178191197182185177
175193178171163176
155166149164170168
3
Résultats graphiques
4
5
6
Analyse de la variance à un facteur
Y = Poids des matières grasses absorbées
X = Type de matière grasse
Modèle :
Yij = + i + ij, avec ij ~ N(0,)
Il y a indétermination puisque
Yij = ( + c) + (i - c) + ij, avec ij ~ N(0,)
pour tout c.
7
Fonction estimable
Modèle :(sur-paramétré)
Yij = + i + ij, avec ij ~ N(0,)
i = E(Yij) = + i estimé par iy
Forme des fonctions estimables :
k k
i i i ii 1 i 1
k k
i i ii=1 i=1
a a ( )
= ( a ) a
est estimé par . k
i ii 1
a y
8
General Estimable Functiona
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
1 -1 -1 -1
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L1 L2 L3 L4
Contrast
Design: Intercept+type_mga.
4 1 4 2 4
3 4
1 2 3
4
1( ) 2( ) 3( )
4( )
1* 2* 3* 4*
( 1 2 3 4)*
L L L
L
L L L L
L L L L
Forme des fonctions estimables :
L1 =
somme des autres coefficients
9
Résultats SPSS
2i i i ij i
i j
ˆ ˆ ˆˆ ˆ ˆLes et vérifiant = y minimisent (y ) k
i i
k
ˆSAS choisit la solution qui correspond à = 0 :
ˆ ˆ + = y , i = 1 à k-1
ˆ = y
i i kˆ y y
Parameter Estimates
Dependent Variable: poids
162.000 4.101 39.504 .000 153.446 170.554 .987
10.000 5.799 1.724 .100 -2.097 22.097 .129
23.000 5.799 3.966 .001 10.903 35.097 .440
14.000 5.799 2.414 .025 1.903 26.097 .226
0a . . . . . .
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
B Std. Error t Sig. Lower Bound Upper Bound
95% Confidence Interval Partial EtaSquared
This parameter is set to zero because it is redundant.a.
SPSS
10
Estimation de
2 2ij i ij ii
i j i j
SCE = Somme des carrés des erreurs
ˆ ˆ = (y ) (y y )
2
1ˆ = Root Mean Square Error
N
iie
N k
22 1ˆ Mean Square Error
N
iie
N k
11
Résultats SPSSTests of Between-Subjects Effects
Dependent Variable: poids
1636.500a 3 545.500 5.406 .007
724537.500 1 724537.500 7180.748 .000
1636.500 3 545.500 5.406 .007
2018.000 20 100.900
728192.000 24
3654.500 23
SourceCorrected Model
Intercept
type_mg
Error
Total
Corrected Total
Type III Sumof Squares df Mean Square F Sig.
R Squared = .448 (Adjusted R Squared = .365)a.
Intercept
1.000
.250
.250
.250
.250
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L1
Contrast
The default display of this matrix is thetranspose of the corresponding L matrix.Based on Type III Sums of Squares.
type_mg
0 0 0
1 0 0
0 1 0
0 0 1
-1 -1 -1
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L2 L3 L4
Contrast
The default display of this matrix is the transpose ofthe corresponding L matrix.Based on Type III Sums of Squares.
Ecrire les contrastes testés
12
Exemple de fonction non estimable
n’est pas estimable
Réponse SPSS
Contrast Coefficients (L' Matrix)a
This L matrix is not estimable.Hypothesis tests cannot be computed.
a.
Contrast Coefficients (L' Matrix)a,b
1
0
0
0
0
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L1
Contrast
The default display of this matrix is thetranspose of the corresponding L matrix.
deltaa.
This L matrix is not estimable.Hypothesis tests cannot be computed.
b.
UNIANOVA poids BY type_mg /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /LMATRIX = "delta" intercept 1 type_mg 0 0 0 0 /PRINT = PARAMETER TEST(LMATRIX) /CRITERIA = ALPHA(.05) /DESIGN = type_mg .
13
Comparaisons multiples des moyennesMéthode de Tukey
(Effectifs des classes inégaux)
On rejette H0 : i = j au risque global de toutes les
comparaisons si :
i j 1i j
1 1 1ˆy y q (k, N k)
n n2
i 1i
max min
ˆoù N = n , = Root MSE et q (k, N k) est le fractile de la loi de
y yl'étendue Studentisée Q = .
ˆ / N / k
14
Résultats SPSS
poids
Tukey HSDa,b
6 162.00
6 172.00 172.00
6 176.00 176.00
6 185.00
.107 .146
type_mgMG4
MG1
MG3
MG2
Sig.
N 1 2
Subset
Means for groups in homogeneous subsets are displayed.Based on Type III Sum of SquaresThe error term is Mean Square(Error) = 100.900.
Uses Harmonic Mean Sample Size = 6.000.a.
Alpha = .05.b.
ConclusionIl y a un effet MG :MG2 MG4
Essayer avec alpha = .107.
15
Comparaisons multiples des moyennesMéthode REGWQ
(Effectifs des classes égaux)
Procédure itérative
- On teste tout d’abord l’homogénéité de toutes les moyennes au risque k. - Si l’on rejette l’homogénéité, alors chaque sous-ensemble de k-1 moyennes est testé au risque k-1; Sinon la procédure est terminée.- Et ainsi de suite...
Choix des p : k = , k-1 = , k-2 = 1 - (1-)(k-2)/k > , etc...
16
Test sur l’homogénéité de p moyennes
Les moyennes sont ordonnées :
On a : n1 = n2 = … = nk = n.
L’homogénéité de p moyennes
est rejetée par REGWQ si
1 2 ki i iy y ... y
s 1 s 2 s pi i iy , y ,..., y
s p s 1 pi i 1
ˆy y q (p, N k)
n
Le seuil critique diminue avec p.
Pour p = k, on retrouve la méthode de Tukey.
17
poids
Ryan-Einot-Gabriel-Welsch Rangea
6 162.00
6 172.00 172.00
6 176.00 176.00
6 185.00
.063 .088
type_mgMG4
MG1
MG3
MG2
Sig.
N 1 2
Subset
Means for groups in homogeneous subsets are displayed.Based on Type III Sum of SquaresThe error term is Mean Square(Error) = 100.900.
Alpha = .05.a.
ConclusionIl y a un effet MG :MG2 MG4
REGWQ donne des résultatsplus significatifs que Tukey.Essayer alpha = .1.
18
Comparaison de k-1 moyennes à une moyenne de contrôle : Le test de Dunnett
On suppose que le témoin est l ’échantillon n° 2.
On rejette H0 : i = 2 au risque si
où d1- est donné dans la table de Dunnett.
i 2 1i 2
1 1ˆ| y y | d
n n
19
UNIANOVA poids BY type_mg /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /POSTHOC = type_mg ( DUNNETT(2)) /CRITERIA = ALPHA(.05) /DESIGN = type_mg .
Résultats SPSS
Multiple Comparisons
Dependent Variable: poids
Dunnett t (2-sided)a
-13.00 5.799 .091 -27.73 1.73
-9.00 5.799 .305 -23.73 5.73
-23.00* 5.799 .002 -37.73 -8.27
(J) type_mgMG2
MG2
MG2
(I) type_mgMG1
MG3
MG4
MeanDifference
(I-J) Std. Error Sig. Lower Bound Upper Bound
95% Confidence Interval
Based on observed means.
The mean difference is significant at the .05 level.*.
Dunnett t-tests treat one group as a control, and compare all other groups against it.a.
20
Test d’un contraste
Modèle : Yij = + i + ij, avec ij ~ N(0,)
iTest :
0 i i
1 i i
H : a 0
H : a 0
0 i i i
1 i i i
H : ( a ) a 0
H : ( a ) a 0
Statistique utilisée :
i i i 2
i i i
ˆ ˆa at ou F = t
ˆ ˆécart type( a a )
avec t t(N-k) et F F(1, N-k) sous H0.
21
Test d’un contraste : Exemples
Modèle :
Yij = + i + ij, avec ij ~ N(0,)
i
1er exemple de test :
3 41 20H :
2 2
0 1 2 3 4H : 0
22
Code SPSS
UNIANOVA poids BY type_mg /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /CRITERIA = ALPHA(.05) /DESIGN = type_mg /CONTRAST (type_mg)=SPECIAL (1 1 -1 -1) /PRINT = PARAMETER TEST(LMATRIX).
porte sur
Demande sur les moyennes
23
Contrast Coefficients (L' Matrix)
0
1
1
-1
-1
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L1
type_mgSpecialContrast
The default display of this matrix is thetranspose of the corresponding L matrix.
Contrast Results (K Matrix)
19.000
0
19.000
8.202
.031
1.892
36.108
Contrast Estimate
Hypothesized Value
Difference (Estimate - Hypothesized)
Std. Error
Sig.
Lower Bound
Upper Bound
95% Confidence Intervalfor Difference
type_mg Special ContrastL1
poids
Dependent
Variable
Test Results
Dependent Variable: poids
541.500 1 541.500 5.367 .031
2018.000 20 100.900
SourceContrast
Error
Sum ofSquares df Mean Square F Sig.
192.3165
8.202t
24
Contrast Results (K Matrix)
-1.750
0
-1.750
3.551
.628
-7.875
4.375
11.250
0
11.250
3.551
.005
5.125
17.375
2.250
0
2.250
3.551
.534
-3.875
8.375
Contrast Estimate
Hypothesized Value
Difference (Estimate - Hypothesized)
Std. Error
Sig.
Lower Bound
Upper Bound
90% Confidence Intervalfor Difference
Contrast Estimate
Hypothesized Value
Difference (Estimate - Hypothesized)
Std. Error
Sig.
Lower Bound
Upper Bound
90% Confidence Intervalfor Difference
Contrast Estimate
Hypothesized Value
Difference (Estimate - Hypothesized)
Std. Error
Sig.
Lower Bound
Upper Bound
90% Confidence Intervalfor Difference
type_mg DeviationContrast
a
Level 1 vs. Mean
Level 2 vs. Mean
Level 3 vs. Mean
poids
Dependent
Variable
Omitted category = 4a.
1 2 3 4TEST : 04i
2e exemple :
25
Contrast Coefficients (L' Matrix)
.000 .000 .000
.750 -.250 -.250
-.250 .750 -.250
-.250 -.250 .750
-.250 -.250 -.250
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
Level 1vs. Mean
Level 2vs. Mean
Level 3vs. Mean
type_mg Deviation Contrasta
The default display of this matrix is the transpose ofthe corresponding L matrix.
Omitted category = 4a.
1 2 3 4TEST : 04i
TEST : 3
jj i
i
26
Test de plusieurs contrastes indépendants
Modèle : Yij = + i + ij, avec ij ~ N(0,)
iTest :
0 i i
1 i i
H : a 0, 1,...,m
H : a 0, au moins un
0 i i i
1 i i i
H : ( a ) a 0, = 1,..., m
H : ( a ) a 0, au moins un
27
Statistique utilisée :
0 1
1
2 2ij ijH H
2ij H
e e / mF
e /(N k)
On rejette H0 au risque de se tromper si F F1-(m, N-k)
Décision :
1i
2 2 2ij H ij i ij iˆ ˆ,
ˆ ˆ( e ) Min (y ) (y y )
0i
0
2 2ij H ij iˆ ˆ ,
vérifiant H
ˆ ˆ( e ) Min (y )
Calcul des sommes de carrés résiduelles :
28
Exemple : Test de l’effet MGTest : H0 : 1 = 2 = 3 = 4
H1 : Au moins un i différent des autres
Test : H0 : 1 = 2 = 3 = 4
H1 : Au moins un i différent des autres
1i
2 2 2ij H ij i ij iˆ ˆ,
ˆ ˆ( e ) Min (y ) (y y )
Somme des carrés intra-groupes
0
2 2 2ij H ij ijˆ ˆ,
ˆ ˆ( e ) Min (y ) (y y)
= Somme des carrés totale
Calcul des sommes de carrés résiduelles :
29
Statistique utilisée :
0 1
1
2 2 2 2ij ijH H ij ij i
22ij iij H
2i i
2ij i
e e / m (y y) (y y ) /(k 1)F
(y y ) /(N k)e /(N k)
n (y y) /(k 1) =
(y y ) /(N k)
On rejette H0 au risque de se tromper si F F1-(k-1, N-k).
Décision :
2i in (y y) Somme des carrés inter-groupes où :
30
Résultats
Tests of Between-Subjects Effects
Dependent Variable: poids
1636.500a 3 545.500 5.406 .007
724537.500 1 724537.500 7180.748 .000
1636.500 3 545.500 5.406 .007
2018.000 20 100.900
728192.000 24
3654.500 23
SourceCorrected Model
Intercept
type_mg
Error
Total
Corrected Total
Type III Sumof Squares df Mean Square F Sig.
R Squared = .448 (Adjusted R Squared = .365)a.
31
Code SPSS
UNIANOVA poids BY type_mg /METHOD = SSTYPE(3) /INTERCEPT = INCLUDE /CRITERIA = ALPHA(.05) /DESIGN = type_mg /CONTRAST (type_mg)=SPECIAL (1 -1 0 0, 1 0 -1 0, 1 0 0 -1) /PRINT = TEST(LMATRIX).
32
Custom Hypothesis Tests
Contrast Coefficients (L' Matrix)
0 0 0
1 1 1
-1 0 0
0 -1 0
0 0 -1
ParameterIntercept
[type_mg=1]
[type_mg=2]
[type_mg=3]
[type_mg=4]
L1 L2 L3
type_mg Special Contrast
The default display of this matrix is the transpose ofthe corresponding L matrix.
Test Results
Dependent Variable: poids
1636.500 3 545.500 5.406 .007
2018.000 20 100.900
SourceContrast
Error
Sum ofSquares df Mean Square F Sig.
33
Identification des outliers : Le RSTUDENT
L’observation i0j0 est-elle un outlier ?
On pose ui0j0 = 1 pour l’observation i0j0 , = 0 sinon.
Modèle : Yij = + i + ui0j0 + ij, avec ij ~ N(0,)
Test : H0 : = 0 (observation i0j0 normale)
H0 : 0 (observation i0j0 outlier)
RSTUDENT : ˆt
ˆécart type( )
à comparer à un t1-/2(N-k-1)
34
Résultats SPSS : Studentized deleted residuals
Régression de Poids sur les variables indicatrices de MG1, MG2,MG3:
MG1 164 172 -.867
MG1 172 172 .
MG1 168 172 -.427
MG1 177 172 .535
MG1 156 172 -1.847
MG1 195 172 2.953
MG2 178 185 -.755
MG2 191 185 .645
MG2 197 185 1.334
MG2 182 185 -.320
MG2 185 185 .
MG2 177 185 -.867
MG3 175 176 -.106
MG3 193 176 1.986
MG3 178 176 .213
MG3 171 176 -.535
MG3 163 176 -1.457
MG3 176 176 .
MG4 155 162 -.755
MG4 166 162 .427
MG4 149 162 -1.457
MG4 164 162 .213
MG4 170 162 .867
MG4 168 162 .645
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type_mg poids Prédiction RSTUDENT
35
36
Normalité des résidus (*)
(*) Utiliser les résidus studentisés ˆ 1
ii
i
et
h
Tests of Normality
.094 24 .200* .972 24 .721StudentizedResidual for poids
Statistic df Sig. Statistic df Sig.
Kolmogorov-Smirnova
Shapiro-Wilk
This is a lower bound of the true significance.*.
Lilliefors Significance Correctiona.
37
38
Tests d’homogénéité des variancesTest de Levene
Analyse de la variance des valeurs absolues des résidussur le facteur étudié :
Levene's Test of Equality of Error Variancesa
Dependent Variable: poids
.361 3 20 .782F df1 df2 Sig.
Tests the null hypothesis that the error variance ofthe dependent variable is equal across groups.
Design: Intercept+type_mga.
39
Conclusion sur le test d’homogénéité des variances
Unless the group variances are extremely different or thenumber of groups is large, the usual ANOVA test is relativelyrobust when the groups are all about the same size
(Documentation de la Proc GLM)
To make the preliminary test on variances is rather like puttingto sea in a rowing boat to find out whether conditions are sufficiently calm for an ocean liner to leave port !
(Box, 1953)