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.