You are on page 1of 9

Prof.

Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Sonipat, Haryana

Testing Normality using


R/R-Studio
Prof. Sanket Vij
Dean & Chairperson
Faculty of Commerce & Management
BPSMV, Khanpur Kalan
Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Functions - I Sonipat, Haryana

To test Normality of Data in R/Rstudio three packages shall be uploaded


i.e. moments, nortest, goftest

• Step 1. : >library(moments) shall be included


• Step 2: > library(nortest) shall be included
• Step 3 : library(goftest) shall be included

Normality can be checked of metric variables only.


Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Functions - II Sonipat, Haryana

• Step 4: Skewness (Variable Name) formula can be used to check skewness. The
value of perfect skewness will be 0.
Example : Skewness(Math)

• Step 5: Kurtosis (Variable Name) formula can be used to check kurtosis. The
normal value of the kurtosis will be 3.
If more than 3 then called as Leucocratic and less than 3 called as Plutocratic.
Example : Kurtosis(Math)
Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Tests - I Sonipat, Haryana

There are three main test of normality : 1. Shapiro Wilk Test 2. Anderson Darling Test
3. Lilliefors Test (Kolmogorov Smirnov)

Shapiro Wilk Test :


Syntax: >shapiro.test(variable name)
Result : Shapiro-Wilk normality test
data: math
W = 0.93305, p-value = 7.445e-05

Decision rule : if the p value is more than .050 than data will be considered as data is
normally distributed.
Anderson-Darling normality test data: math A = 2.0163, p-value = 3.61e-05
Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Tests - II Sonipat, Haryana

Anderson Darling Test :

Syntax: >ad.test(variable name)


Result : Anderson-Darling normality test
data: math
A = 2.0163, p-value = 3.61e-05

Decision rule : if the p value is more than .050 than data will be considered as data is
normally distributed.
Lilliefors (Kolmogorov-Smirnov) normality test data: math D = 0.10997, p-value = 0.004589
Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Tests - III Sonipat, Haryana

Lilliefors Test (Kolmogorov Smirnov ):

Syntax: >lillie.test(variable name)


Result : Lilliefors (Kolmogorov-Smirnov) normality test
data: math
D = 0.10997, p-value = 0.004589

Decision rule : if the p value is more than .050 than data will be considered as data is
normally distributed.
Prof. Sanket Vij,
Normality Related Graphs Dean, FCM, BPSMV,
Khanpur Kalan,
Sonipat, Haryana
Quartile Quartile Plot :
Syntax >qqnorm(variable Name) -

To display regression line in QQ plots use> qqline(variable name, col = , lwd= )


• Col – Colour of the line . we can give 1 to 9 number it will display nine different colours
• LWD – Line Width
• Example >QQline(variable Name , Col = 2, LWD = 4)
Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Normality Related Graphs Sonipat, Haryana

to give two or more commands on the same line use ; (semicolon)

Example >QQNORM(variable name);QQLINE(variable name, COL = , LWD=)


Prof. Sanket Vij,
Dean, FCM, BPSMV,
Khanpur Kalan,
Sonipat, Haryana

Thank You All

You might also like