Académique Documents
Professionnel Documents
Culture Documents
Zahidi
Dataset <-readXL("C:/Users/Hp/Desktop/ZahidiMasterFPT/ANOVA/AnovaPou.xlsx",
Cliquer sur Graphes, Boite de dispersion puis voir le graphique dans plot de R studio.
R répond
[1] "1063" "1228" "1174" "1173" "900" "1064" "896" "1118" "1175" "1238"
R répond
[1] "900" "896" "2437" "890" "895" "881" "898" "891" "885" "1006"
Contrainte: ..????
> options(contrasts=c("contr.sum","contr.sum"))
> summary(LinearModel.1)
Call:
Residuals:
Coefficients:
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
-Modèle
- Tests d’hypothèse
- Table de l’ANOVA
Anova(LinearModel.1, type="II")
Response: Total
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
data(senso)
res <- AovSum(Score~ Product + Day , data=senso)
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
res
R répond:
Ftest
SS df MS F value Pr(>F)
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> res
Ftest
SS df MS F value Pr(>F)
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Ttest
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Ttest
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Dans R
- Taper la ligne de commande suivante pour importer le fichier depuis le
bureau :
donnees=read.table(file.choose(),header=TRUE,sep="\t")
- Taper entrée et choisir le fichier du répertoire.
- Taper entrée on vous donne le choix du fichier
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
is.data.frame(donnees)
R répond
names(donnes)
R répond
[1] "Date" "Stade" "Position" "Vivant" "Mort" "Parasite" "Total"
library(FactoMineR)
R répond
Warning message:
le package ‘FactoMineR’ a été compilé avec la version R 3.3.3
Ttest
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.590736 0.081464 56.3528 < 2e-16 ***
Product - 1 0.237057 0.120675 1.9644 0.05628 .
Product - 2 -0.284745 0.114663 -2.4833 0.01720 *
Product - 3 0.047688 0.118456 0.4026 0.68935
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
Ttest
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.5842929 0.0871239 52.6181 < 2e-16 ***
Product - 1 0.2557071 0.1225836 2.0860 0.04357 *
Product - 2 -0.2509596 0.1203159 -2.0858 0.04358 *
Product - 3 -0.0047475 0.1266521 -0.0375 0.97029
Day - 1 0.8120707 0.0871239 9.3209 < 2e-16 ***
Day - 2 -0.8120707 0.0871239 -9.3209 < 2e-16 ***
Product - 1 : Day - 1 0.0279293 0.1225836 0.2278 0.82096
Product - 2 : Day - 1 -0.1454040 0.1203159 -1.2085 0.23412
Product - 3 : Day - 1 0.1174747 0.1266521 0.9275 0.35935
Product - 1 : Day - 2 -0.0279293 0.1225836 -0.2278 0.82096
Product - 2 : Day - 2 0.1454040 0.1203159 1.2085 0.23412
Product - 3 : Day - 2 -0.1174747 0.1266521 -0.9275 0.35935
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Notions théoriques
Définition
• Étude simultanée d’un facteur A à p modalités et d’un facteur B à q modalités.
• Pour chaque couple de modalités (A, B) :
o On a un échantillon ( et ).
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
Hypothèses
: le facteur A n’a pas d’influence sur la moyenne des populations.
Voir feuille 1 – 2 :
• variance expérimentale
• Moyenne générale
• Variance totale
Exemple :
Problématique :
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
Ecrire ce tableau sous forme standard, qui est celle utilisée dans la plupart des
logiciels et en particulier avec le logiciel R, c’est-à-dire avec trois colonnes, une pour
la semaine, une pour l’espèce et une pour la masse, et 24 lignes, une pour chaque sachet.
Objectif :
- Deux d’entre elles sont des variables contrôlées, l’espèce d’arbre, qualitative à
trois modalités, et la semaine qui peut être considérée comme qualitative à quatre
modalités.
Nous testons :
Contre
Nous testons :
L’effet de l’interaction entre les facteurs F1 et F2. Il consiste à comparer
* H0 : les IJ paramètres (αβ)ij sont tous nuls
Contre
Annexe :
Dataset <-
readXL("C:/Users/Hp/Desktop/ZahidiMasterFPT/ANOVA/Poudyna
MasterFPTRcmdr.xlsx",
stringsAsFactors=TRUE)
options(contrasts=c("contr.sum","contr.sum"))
summary(LinearModel.1)
anova(LinearModel.1)
library(MASS, pos=17)
Confint(LinearModel.1, level=0.95)
When data is unbalanced, there are different ways to calculate the sums of squares for ANOVA.
There are at least 3 approaches, commonly called Type I, II and III sums of squares (this notation
seems to have been introduced into the statistics world from the SAS package but is now
widespread). Which type to use has led to an ongoing controversy in the field of statistics (for an
overview, see Heer [2]). However, it essentially comes down to testing different hypotheses about
the data.
Type I, II and III Sums of Squares
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
Consider a model that includes two factors A and B; there are therefore two main effects, and an
interaction, AB. The full model is represented by SS(A, B, AB).
Other models are represented similarly: SS(A, B) indicates the model with no interaction, SS(B,
AB) indicates the model that does not account for effects from factor A, and so on.
The influence of particular factors (including interactions) can be tested by examining the
differences between models. For example, to determine the presence of an interaction effect, an
F-test of the models SS(A, B, AB) and the no-interaction model SS(A, B) would be carried out.
The notation shows the incremental differences in sums of squares, for example SS(AB | A, B)
represents “the sum of squares for interaction after the main effects”, and SS(A | B) is “the sum of
squares for the A main effect after the B main effect and ignoring interactions” [1].
The different types of sums of squares then arise depending on the stage of model reduction at
which they are carried out. In particular:
Type II:
SS(A | B) for factor A.
SS(B | A) for factor B.
This type tests for each main effect after the other main effect.
Note that no significant interaction is assumed (in other words, you should test for interaction
first (SS(AB | A, B)) and only if AB is not significant, continue with the analysis for main
effects).
Faculté Polydisciplinaire Taroudant Master PACQ Cours de Statistique Pr. Zahidi
If there is indeed no interaction, then type II is statistically more powerful than type III (see
Langsrud [3] for further details).
Computationally, this is equivalent to running a type I analysis with different orders of the
factors, and taking the appropriate output (the second, where one main effect is run after
the other, in the example above).
Type III:
SS(A | B, AB) for factor A.
SS(B | A, AB) for factor B.
This type tests for the presence of a main effect after the other main effect and interaction.
This approach is therefore valid in the presence of significant interactions.
However, it is often not interesting to interpret a main effect if interactions are present
(generally speaking, if a significant interaction is present, the main effects should not be
further analysed).
If the interactions are not significant, type II gives a more powerful test.
NOTE: when data is balanced, the factors are orthogonal, and types I, II and III all give the same
results.
Summary: Usually the hypothesis of interest is about the significance of one factor while
controlling for the level of the other factors. This equates to using type II or III SS. In general, if
there is no significant interaction effect, then type II is more powerful, and follows the principle of
marginality. If interaction is present, then type II is inappropriate while type III can still be used,
but results need to be interpreted with caution (in the presence of interactions, main effects are
rarely interpretable).