Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to test normality using R?

Description

To test the normality of the given data in R programming.

Process

Visual methods:

   Histogram (R Function : hist())

   Q-Q plot (R Function : plot(qqnorm()))

   Density plot : (R Function : plot(density()))

Normality test:

   R Package : nortest

   Anderson- Darling test (R Function : test() )

   Shapiro- Wilk test

Sapmle Code

#Normality Test in R
#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”)
data<-read.xlsx(“ExcelInput.xlsx”,sheetIndex=1)
print(data)
View(data)

#Check Normality
#Histogram Test for Normality
x1<-data$speed
x2<-data$dist
hist(x1,col=”yellow”)
hist(x2,col=”violet”)

#Q-Q plot
plot(qqnorm(x1))
#Generating a line for Q-Q plot
qqline (x1, col=2)
title(main=”Normal Q-Q Plot”)

#Density plot
plot(density(x1))
polygon(density(x1),col=”blue”)

#Anderson – Darling test for Normality
#install.packages(“nortest”)
library(“nortest”)
ad.test(x1)

#Shapiro-Wilk test for Normality
shapiro.test(x1)

Screenshots
test normality using R
Get and Set Working Directory
Read file from Excel
Density plot
Check Normality
Normality Test in R