#5, First Floor, 4th Street , Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 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 test Correlation using different methods in R?
Description

To test the correlation using different methods using R programming.

Process

   Check Normality

   Passes Normality

   Parametric Correlation test - Pearson Method

   Not Passes Normality

   Non - Parametric test - Spearman rank and Kendall

   rank test

Sapmle Code

#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”)

Screenshots