Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement the Non-Parametric Hypothesis testing in R?

Description

To implement the Non-Parametric Hypothesis Testing using R.

Process
Assumptions for Non-Parametric test:
  • Data are non-normal and cannot be transformed
  • From a sample that is too small for thecentral limit theorem to lead to normalityof averages
  • From a distribution not covered byparametric methods
  • From an unknown distribution
  • Nominal or ordinal
One Sample sign test :
  • A sign test is used to decide whether a binomial distributionhas the equalchance of success and failure.
  • Probability of success -- It is theprobability of success of the newproduct.
  • H0 : Two products are equally popular
  • H1 : Customers preferring one productmore than the other product
  • R Function : test(x=, n=)
  • x -- Number of Success
  • N -- Number of trials
Wilcoxon signed rank test:
  • An equivalent test for two pairedt, z test
  • H0 : Two means are equal.
  • H1 : Difference of the mean isnot equal.
  • R Function : test(x,y, paired =)
  • x , y -- numeric variable
  • paired -- logical value for thepaired test
  Wilcoxon rank sum test or mann- Whitney test :
  • An equivalent test for two unpaired t,z test in R.
  • H0 : Two means are equal.
  • H1 : Difference of the mean isnot equal.
  • R Function : test(x~y)
  • x -- numeric
  • y -- factor
  Chi- Squared test :
  • Chi - Squared is a non- parametric test
  • H0 : Two Variables are independent.
  • H1 : Two Variables are relative.
  • R Function :test(tab)
  • tab -- contingency table betweentwo variables
Levene’s Test :
  • An equivalent test for variance test
  • H0 : Two variance are equal.
  • H1 : Two variance are not equal.
  • R Package : car
  • R Function : leveneTest(x~z)
  • x -- numeric
  • z - factor
  Kruskal - Wallis test :
  • An equivalent test for one way ANOVA
  • H0: Means of different groups are same
  • H1: Atleast one sample mean is notequal to others
  • R Function : test(x~y)
  • x -- factor
  • y -- numeric
Sapmle Code

#Non – Parametric Hypothesis testing
#Input

x<-c(1090,500,9,16,29,37,41,59,735,923)
y<-c(800,276,65,9,466,37,955,749,3787,577)
z<-c(0,1,1,0,0,0,1,1,0,0)

#Checking Normality
#Anderson Darling test
library(“nortest”)
ad.test(x)
ad.test(y)

#Shapiro test
shapiro.test(x)
shapiro.test(y)

#One Sample sign test
binom.test(x=10,n=18)

#Wilcoxon signed rank test
#Equivalent test for two dependent samples t, z test
wilcox.test(x,y,paired = T)

#Wilcoxon rank sum test or Mann- Whitney test
#Equivalent test for two independent samples t, z test
wilcox.test(y,x)

#If x is numeric and z is binary factor
wilcox.test(x~z)

#Chi- Squared test
#Contingency table
tab<-table(x,y)
print(tab)
chisq.test(tab)

#Levene’s test
#Equivalent test for f test
library(“car”)
z<-as.factor(z)
leveneTest(x~z)

#Kruskal- Wallis test
#Equivalent test for one way ANOVA
kruskal.test(mtcars$am~mtcars$mpg)

Screenshots
Non-Parametric Hypothesis testing in R
implement the Non-Parametric Hypothesis testing
Assumptions for Non-Parametric test
Data are non-normal and cannot be transformed
non- parametric test
ominal or ordinal
implement the Non-Parametric Hypothesis testing in R
Parametric Hypothesis testing
Input