Skip to content

Data Science Tutorials

For Data Science Learners

  • Hypothesis Testing in R Programming
    Hypothesis Testing in R Programming R
  • Descriptive Statistics in R R
  • How to do Conditional Mutate in R
    How to do Conditional Mutate in R? R
  • Apply central limit throem in r
    Apply Central Limit Theorem in R R
  • Psychological Experimentation Software
    Psychological Experimentation Software: OpenSesame Opensesame
  • How to check regression analysis heteroscedasticity in R
    How to check regression analysis heteroscedasticity in R R
  • How to Recode Values in R
    How to Recode Values in R R
  • Create new variables from existing variables in R
    Create new variables from existing variables in R R
Anderson-Darling Test in R With Examples

Anderson-Darling Test in R With Examples

Posted on September 19September 14 By Admin No Comments on Anderson-Darling Test in R With Examples

Anderson-Darling Test in R, the Anderson-Darling Test is a statistical test used to determine whether a given dataset is drawn from a particular distribution, such as the normal distribution.

In this article, we will demonstrate how to conduct an Anderson-Darling Test in R using inbuilt datasets.

Formulation of the Hypothesis:

Before conducting the Anderson-Darling Test, it is necessary to formulate the null and alternative hypotheses.

The null hypothesis (H0) assumes that the dataset is drawn from a specific distribution. It is usually written as:

H0: The dataset is drawn from the specific distribution.

The alternative hypothesis (H1) assumes that the dataset is not drawn from the specific distribution. It is usually written as:

H1: The dataset is not drawn from the specific distribution.

In the following sections, we will provide examples of how to conduct an Anderson-Darling Test in R.

The pheatmap function in R » Data Science Tutorials

Example 1: Testing the Normality of Inbuilt Dataset – ‘mtcars’

In this example, we will use the inbuilt mtcars dataset to test whether the dataset is normally distributed.

First, we will load the mtcars dataset:

data(mtcars)

Next, we can extract a specific variable from the dataset:

mpg <- mtcars$mpg
library(nortest)

Then, we can conduct the Anderson-Darling Test using the ‘ad.test’ function:

ad_test <- ad.test(mpg)
ad_test
Anderson-Darling normality test

data:  mpg
A = 0.57968, p-value = 0.1207

The output will display the test statistic, the p-value, and a conclusion based on the test results.

In this case, because the p-value is greater than 0.05, we fail to reject the null hypothesis and conclude that the mpg variable of mtcars dataset is normally distributed.

Example 2: Testing the Exponentiality of Inbuilt Dataset – ‘trees’

In this example, we will use the inbuilt trees dataset to test whether the dataset is exponentially distributed.

First, we will load the trees dataset:

data(trees)

Then, we can extract a specific variable from the dataset:

height <- trees$Height

Next, we can conduct the Anderson-Darling Test using the ‘ad.test’ function:

ad_test <- ad.test(height)

Note that we have specified the distribution as “exp” to test if the height variable of the trees dataset is exponentially distributed.

ad_test
Anderson-Darling normality test

data:  height
A = 0.35926, p-value = 0.4282

The output will display the test statistic, the p-value, and a conclusion based on the test results.

In this case, because the p-value is less than 0.05, we reject the null hypothesis and conclude that the height variable of the trees dataset is not exponentially distributed.

Conclusion:

In this article, we have demonstrated how to conduct an Anderson-Darling Test in R using inbuilt datasets.

The Anderson-Darling Test is a statistical test used to determine whether a given dataset is drawn from a specific distribution.

By utilizing the examples provided in this article, researchers can use the Anderson-Darling Test to test hypotheses related to the distribution of their datasets.

Data Analyst – Remote »

R

Post navigation

Previous Post: Jarque-Bera Test in R With Examples
Next Post: Wald Test in R With Examples

Related Posts

  • Is R or Python Better for Data Science in Bangalore
    Is R or Python Better for Data Science in Bangalore R
  • Two Sample Proportions test in R
    Two Sample Proportions test in R-Complete Guide R
  • How to perform TBATS Model in R
    How to perform TBATS Model in R R
  • Best Books on Generative AI Course
  • Export output as text in R R
  • Is Data Science a Dying Profession
    Is Data Science a Dying Profession? R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Best Prompt Engineering Books
  • Understanding Machine Learning and Data Science
  • Best Git Books
  • Top 5 Books to Learn Data Engineering
  • Mastering R Programming for Data Science: Tips and Tricks
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • How to perform TBATS Model in R
    How to perform TBATS Model in R R
  • How to Check if a Directory Exists in R
    How to Check if a Directory Exists in R R
  • Two-Way ANOVA Example in R
    Two-Way ANOVA Example in R-Quick Guide R
  • Create new variables from existing variables in R
    Create new variables from existing variables in R R
  • How To Become a Business Intelligence Analyst
    How To Become a Business Intelligence Analyst Course
  • Methods for Integrating R and Hadoop
    Methods for Integrating R and Hadoop complete Guide R
  • bootstrapping-in-r
    Bootstrapping in R R
  • Is Data Science a Dying Profession
    Is Data Science a Dying Profession? R

Privacy Policy

Copyright © 2025 Data Science Tutorials.

Powered by PressBook News WordPress theme