VOOZH about

URL: https://www.geeksforgeeks.org/r-machine-learning/how-to-test-for-normality-in-r/

⇱ How to Test for Normality in R - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Test for Normality in R

Last Updated : 23 Jul, 2025

Normality testing is important in statistics since it ensures the validity of various analytical procedures. Understanding whether data follows a normal distribution is critical for drawing appropriate conclusions and predictions. In this article, we look at the methods and approaches for assessing normalcy in the R Programming Language.

What is Normality Testing?

Normality testing determines if a particular dataset has a normal distribution. A normal distribution, sometimes called a Gaussian distribution, is distinguished by a symmetric bell-shaped curve. This assessment is critical since many statistical procedures, including t-tests, ANOVA, and linear regression, are based on the assumption of normality.

How to Perform Normality Testing in R

To do normality testing in R, first, install and load the required packages. Then, import your dataset into the R environment and perform the necessary normality test. Typically, while interpreting the data, the test statistic and related p-value are assessed.

Types of Normality Tests in R

In R, several methods are available for testing normality including :

  1. Shapiro-Wilk test
  2. Kolmogorov-Smirnov test
  3. Anderson-Darling test

Each test includes unique assumptions and statistical features, making it appropriate for a variety of contexts.

1. Shapiro-Wilk Test

The Shapiro-Wilk test is a statistical test that determines if a dataset represents a regularly distributed population.

Output:

 Shapiro-Wilk normality test

data: data
W = 0.97289, p-value = 0.03691

2. Kolmogorov-Smirnov Test

The Kolmogorov-Smirnov test is a non-parametric test that determines if a dataset has a certain distribution.

Output:

 Asymptotic one-sample Kolmogorov-Smirnov test

data: data
D = 0.095166, p-value = 0.3255
alternative hypothesis: two-sided

3. Anderson-Darling Test

The Anderson-Darling test is a statistical test that determines if a dataset follows a specific distribution, notably the normal distribution.

Output:

 Anderson-Darling normality test

data: data
A = 0.13499, p-value = 0.978

Implications of Different P-Values

The significance of the p-value derived from normalcy testing cannot be overstated. A p-value that is less than a selected significance threshold (usually 0.05) indicates evidence that the null hypothesis of normality is not true. A larger p-value, on the other hand, suggests that there is insufficient data to rule out the null hypothesis. Comprehending these ramifications facilitates an efficient interpretation of the findings.

Graphical Methods for Testing Normality

  • Q-Q Plots (Quantile-Quantile Plots)
  • Histograms
  • Box Plots and Density Plots

Q-Q Plots (Quantile-Quantile Plots)

Q-Q plots are a type of graphical tool that are used to determine if a dataset is distributed normally or not. Q-Q plots may be made in R with the qqnorm() and qqline() functions. Q-Q plots reveal various patterns that might shed light on the deviation from normalcy.

Output:

👁 gh
Normality in R

Histograms

Histograms offer a graphic depiction of the data distribution. Histograms may be made in R by utilising the hist() function. An analysis of the histogram's form might reveal departures from the norm.

Output:

👁 gh
Normality in R

Box Plots and Density Plots

For examining the data distribution graphically, box plots and density plots are helpful. Density plots depict the distribution of the data as a smooth curve, whereas box plots highlight the dispersion and central tendency of the distribution. When evaluating data distribution, these graphs can be used in addition to traditional normalcy tests.

Output:

👁 gh
Normality in R

Conclusion

In conclusion, checking for normalcy is an important stage in statistical analysis since it ensures the validity of subsequent inference and decision-making. Using a mix of numerical tests.

Comment
Article Tags:

Explore