To test the correlation using different methods using R programming.
Check Normality
Passes Normality
Parametric Correlation test - Pearson Method
Not Passes Normality
Non - Parametric test - Spearman rank and Kendall
rank test
#Correlation Test
#install caret package
#install.packages(“caret”)
library(“caret”)
#Get and Set Working Directory
print(getwd())
setwd(“/home/soft13”)
getwd()
#Read file from Excel
#install.packages(“xlsx”)
library(“xlsx”)
dataSet<-read.xlsx(“ExcelInput.xlsx”,sheetIndex=1)
print(dataSet)
View(dataSet)
#Check Normality
library(“nortest”)
x1<-sample(dataSet$speed)
x2<-sample(dataSet$dist)
ad.test(x1)
ad.test(x2)
#Parametric Correlation
#Correlation Test – Pearson
cor.test(dataSet$speed,dataSet$dist,method=”pearson”)
#Non- Parametric Correlation
#Correlation test- Spearman Rank
cor.test(dataSet$speed,dataSet$dist,method=”spearman”)
#Correlation test – Kendall Rank
cor.test(dataSet$speed,dataSet$dist,method=”kendall”)