0% found this document useful (0 votes)
62 views5 pages

ANOVA

The document discusses the ANOVA (Analysis of Variance) test in R programming, explaining its purpose in investigating relationships between categorical and continuous variables. It outlines the null and alternative hypotheses, types of ANOVA (one-way and two-way), and provides R code for conducting a one-way ANOVA test with sample data. The results include an ANOVA table detailing treatment means and significance levels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views5 pages

ANOVA

The document discusses the ANOVA (Analysis of Variance) test in R programming, explaining its purpose in investigating relationships between categorical and continuous variables. It outlines the null and alternative hypotheses, types of ANOVA (one-way and two-way), and provides R code for conducting a one-way ANOVA test with sample data. The results include an ANOVA table detailing treatment means and significance levels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

ACHARYA NAGARJUNA UNIVERSITY

Nagarjuna Nagar, Guntur-522510


DEPARTMENT OF STATISTICS

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.

 Alternate Hypothesis: The opposite of the null hypothesis is the


alternative hypothesis. It implies that there is a significant relationship,
difference, or link among the population’s variables. Depending on the
study question or the nature of the issue under investigation, it may take
several forms. Alternative hypotheses are sometimes referred to as H1 or
HA.

ANOVA tests are of two types:


 One-way ANOVA: One-way When there is a single categorical
independent variable (also known as a factor) and a single continuous
dependent variable, an ANOVA is employed. It seeks to ascertain
whether there are any notable variations in the dependent variable’s
means across the levels of the independent variable.
 Two-way ANOVA: When there are two categorical independent variables
(factors) and one continuous dependent variable, two-way ANOVA is
used as an extension of one-way ANOVA. You can evaluate both the
direct impacts of each independent variable and how they interact with
one another on the dependent variable.

One Way ANOVA

1 2 ---------- i ------- K

1 y11 y21 yi1 yk1

2 y12 y22 yI2 yk2

r y1r y2r yir ykr

Total y1. y2. yi. yk. y..

Yij= μ +ti+ ¿
i
j

Where
Yij – is the jth observation in the ith subclass
- general mean effect
μ

ti – additive effect of ith subclass

¿
i
– random error ~ N(0,Sigma^2)
j

Null Hypothesis: -

H0: The effect of all subclass are equal


i.e
t
1
¿
t
2
¿
t
3
¿
,
,
,
,
,
,
,
,
,
,
,
¿
t
k
¿
0

K
i=1

∑ t i=0
Computation: -
Correction Factor
C
.
F
¿
G2
N

Sum of squares due to subclass


T
¿
K
i .2 Y
∑ r
i = 1

Y . .2
−¿
K r
¿
K
Y i .2
∑ r
i = 1
− ¿ C
.
F

Total Sum of Squares


T
.
S
.
S
¿
K r

∑ ∑ 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=**/*

Total Kr-1 T.S.S


¿
¿
( K r −1 )
− ¿ ( ¿ k ¿− ¿ 1 ¿ )

¿
¿
¿
T
.
S
.
S
− ¿ T

R Code: -
#CRD
crd.data=read.csv("crd5.csv",header=T);

cat("\n the given crd data= \n");

print(crd.data);

rownames(crd.data)=crd.data[,1];

crd.data=crd.data[,-1];

cat("\n Treatment Means:");

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:

The given crd data=

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

39.00 43.50 43.50 63.75 51.00

Analysis of Variance Table

Response: Yield

Df Sum Sq Mean Sq F value Pr(>F)

Treatment 4 1513.80 378.45 13.428 7.575e-05 ***

Residuals 15 422.75 28.18

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

You might also like