ANOVA
ANOVA
ASSIGNMENT
Paper No : 1.2
Paper Name : Statistical Computing with R
Submitted To : Prof. A.VASUDEVA RAO(M.Sc., M.phil.,Ph.D)
Submitted By : D.Gopalakrishna
M.Sc. Statistics
1st Semester
Y25ST20006
ANOVA (Analysis of Variance) Test in R Programming
ANOVA also known as Analysis of variance is used to investigate relations
between categorical variables and continuous variables in the R programming
language. It is a type of hypothesis testing for population variance. It enables us
to assess whether observed variations in means are statistically significant or
merely the result of chance by comparing the variation within groups to the
variation between groups. The ANOVA test is frequently used in many
disciplines, including business, social sciences, biology, and experimental
research.
R – ANOVA Test
ANOVA tests may be run in R programming, and there are a number of
functions and packages available to do so.
ANOVA test involves setting up:
Null Hypothesis: The default assumption, or null hypothesis, is that
there is no meaningful relationship or impact between the variables. It
stands for the absence of a population-wide link, difference, or effect.
The statement that two or more groups are equal or that the effect size
is zero is sometimes expressed as the null hypothesis. The null
hypothesis is commonly written as H0.
1 2 ---------- i ------- K
Yij= μ +ti+ ¿
i
j
Where
Yij – is the jth observation in the ith subclass
- general mean effect
μ
¿
i
– random error ~ N(0,Sigma^2)
j
Null Hypothesis: -
K
i=1
∑ t i=0
Computation: -
Correction Factor
C
.
F
¿
G2
N
Y . .2
−¿
K r
¿
K
Y i .2
∑ r
i = 1
− ¿ C
.
F
∑ ∑ Y i j
2
−C . F
i=1 j=1
ANOVA TABLE: -
SV DOE SS MSS Fcal Ftab
Subclas T1=T-K-
K-1 T T1/E1 F(K-1,*)
s 1
Error * ** E1=**/*
¿
¿
¿
T
.
S
.
S
− ¿ T
R Code: -
#CRD
crd.data=read.csv("crd5.csv",header=T);
print(crd.data);
rownames(crd.data)=crd.data[,1];
crd.data=crd.data[,-1];
print(sapply(crd.data,mean));
cat("\n\n");
scrd.data=stack(crd.data);
names(scrd.data)=c("Yield","Treatment");
scrd=aov("Yield~Treatment",scrd.data);
print(anova(scrd));
Output:
Blocks T1 T2 T3 T4 T5
1 A 34 36 48 59 46
2 B 40 46 36 62 48
3 C 42 50 40 64 52
4 D 40 42 50 70 58
Treatment Means: T1 T2 T3 T4 T5
Response: Yield
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1