0% found this document useful (0 votes)
36 views4 pages

Non Par Source Code

The document demonstrates various statistical tests including the Pearson's correlation test, Wilcoxon sign rank test, Mann-Whitney U test, Kruskal-Wallis test, and chi-square test through examples using sample data. Datasets are created and subsets are applied. Assumptions of the tests are checked using Shapiro-Wilk normality test. Statistical tests are performed and results analyzed.

Uploaded by

Philip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Non Par Source Code

The document demonstrates various statistical tests including the Pearson's correlation test, Wilcoxon sign rank test, Mann-Whitney U test, Kruskal-Wallis test, and chi-square test through examples using sample data. Datasets are created and subsets are applied. Assumptions of the tests are checked using Shapiro-Wilk normality test. Statistical tests are performed and results analyzed.

Uploaded by

Philip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

## Pearson's example 1

#Normality test

number_of_person<-c(5,6,14,19,15,11,18,22,26)

coffee_sold<- c(10,20,30,40,30,20,40,40,50)

shapiro.test(number_of_person)

shapiro.test(coffee_sold)

#Statisticial Test

cor.test(number_of_person,coffee_sold,method = "pearson",conf.level = 0.95)

## Wilcoxon Sign rank test


#Example 1

weight1 <-c(198,237,233,179,219,169,222,167,199,233,179,158,157,216,355,151)

weight2 <-c(196,233,231,181,217,166,219,167,200,229,181,153,151,213,255,146)

differrence <-weight1-weight2

shapiro.test(differrence)

#statistical test

weight1 <-c(198,237,233,179,219,169,222,167,199,233,179,158,157,216,355,151)

weight2 <-c(196,233,231,181,217,166,219,167,200,229,181,153,151,213,255,146)

wilcox.test(weight1,weight2, paired =TRUE, alternative = "two.sided",

exact = FALSE)
## Mann-Witney U test
#Example 1

results<-c(105,119,100,97,96,101,94,95,98,96,99,94,89,96,93,88,105,88)

RER <-c(replicate(9,"placebo"),replicate(9,"caffeine"))

#create a data frame

data_frame<-data.frame(results,RER)

data_frame

#apply subset, to get the data "visual" and "textual" from dataframe

Placebo<-subset(data_frame,RER=="placebo")

Caffeine<-subset(data_frame,RER=="caffeine")

## Shapiro wilk Test

shapiro.test(Placebo$results)

shapiro.test(Caffeine$results)

## statistical test

wilcox.test(results~RER, data = data_frame, mu=0,

alternative ="less", conf.level = 0.95, exact = FALSE)


##KRUSKAL WALLIS TEST

gains<-c(63,-261,-153,-13,965,0,-652,4724,-2,0,-86,2239,171,40,1395)

group <-c(replicate(5,"group1"),replicate(6,"group2"), replicate(4,"group3"))

#create a data frame

data_frame<-data.frame(gains,group)

data_frame

#apply subset, to get the data "visual" and "textual" from dataframe

group1<-subset(data_frame,group=="group1")

group2<-subset(data_frame,group=="group2")

group3<-subset(data_frame,group=="group3")

# Shapiro wilk Test

shapiro.test(group1$gains)

shapiro.test(group2$gains)

shapiro.test(group3$gains)

#Statistical Test

kruskal.test(gains~group, data = data_frame)


#CHI-SQUARE TEST

table(School_Dataset$Gender,School_Dataset$`Drop Reason`)

table(School_Dataset$`Drop Reason`,School_Dataset$Gender)

chisq.test(School_Dataset$`Drop Reason`,School_Dataset$Gender)

You might also like