importing and sortingd data
Linear effects of Equation
Xij=mu+Ti+ Eij
Here mu=Grand mean
Ti=Effect of population
Eij=RandomError
# Nullhypothesis(Ho): u1=u2=u3=u4
#Alternative Hypothesis (Ha): Atleast one of u differs.
#install.packages("tidyr")
library(tidyr)
#install.packages("dplyr")
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
M1<-c(.34,.12, 1.23,.70,1.75,.12)
M2<-c(.91,2.94,2.14,2.36,2.86,4.55)
M3<-c(6.31,8.37,9.75,6.09,9.82,7.24)
M4<-c(17.15,11.82,10.97,17.20,14.35,16.82)
dat<-data.frame(M1,M2,M3,M4)
d<-c(M1,M2,M3,M4)
R<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
data2 <- pivot_longer(data=dat,c(M1,M2,M3,M4))
qqnorm(data2$value)
#Therefore, we can observe the data appears to be quiet normal based on q-q norm
boxplot(d~R,main="Boxplot",xlab="Method",ylab="observations")
By the boxplot we can observe that variance are not equal and fourth variance is high.
#kruskal wallis test
kruskal.test(value~name,data = data2)
##
## Kruskal-Wallis rank sum test
##
## data: value by name
## Kruskal-Wallis chi-squared = 21.156, df = 3, p-value = 9.771e-05
Therefore by kruskals test P value is 9.771e-05 which is very low, so we can reject the null hypothesis.
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
boxcox(value~name,data=data2)
lamda=0.5
data3<-(d^lamda)
boxplot(data3~R,main="boxplot",xlab="Method",ylab="observations")
Based on boxplot we can say that variances are equal and sample size is small so that we are going for kruskals test again
anova_model<-aov(data3~R)
summary(anova_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## R 1 32.53 32.53 251.2 1.62e-13 ***
## Residuals 22 2.85 0.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Based on this P value is low, so we can reject null hypothesis