Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement One Way ANOVA in R?

Description

To implement the one way ANOVA using R programming.

Process
One Way ANOVA:
  • Compares means of more than two independent groups.
  Hypothesis:
  • H0: Means of different groups are same
  • H1: Atleast one sample mean is not equal to others
  Assmptions of One-Way ANOVA:
  • Groups are independent with each other
  • Data of each group are normally distributed
  • Normal Population should have common variance
  R Functions :
  • R Function :aov(formula)
  • formula -- a formula specifying the model
  • R Function : TukeyHSD(x) -- to evaluate pair means
  • x -- a fitted model object, usually
Interpretation of plotted pairwise t test :
  • Significant differences are the ones which not cross the zero value.
Sapmle Code

#One way ANOVA
#Input
View(iris)
input<-iris$Sepal.Width
input1<-iris$Species

#Box Plot
boxplot(input~input1,col=c(“green”,”yellow”,”blue”),horizontal=FALSE)
title(main = “Box Plot”,xlab = “Species”,ylab = “Petal.Width”)

#Normality of data of each group
#Histogram
#install.packages(“FSA”)
library(“FSA”)
hist(Sepal.Length~Species,data=iris,col=c(“red”,”yellow”,”blue”))

#Mean value
mean_val<-round(tapply(input,input1,mean),digits = 2)
print(mean_val)

#Plotting Means
#install.packages(“gplots”)
library(“gplots”)
plotmeans(input~input1,col = “red”,mean.labels = TRUE,pos=4,xlab = “Species”,ylab = “Petal Width”,main=”Plot of Petal Width means by Species”,pch=15,cex=1)

Screenshots
implement One Way ANOVA in R
One Way ANOVA
Normality of data of each group
Data of each group are normally  distributed
Normal Population should have common  variance
Plot of Petal Width means by Species
Interpretation of plotted pairwise t test
Compares means of more than two  independent groups