Jarque-Bera Test in R With Examples
Jarque-Bera Test in R, the Jarque-Bera test is a statistical test used to determine whether a given dataset is distributed normally or not.
It tests whether the skewness and kurtosis of the dataset are consistent with a normal distribution. In this article, we will demonstrate how to conduct a Jarque-Bera test in R with inbuilt datasets.
Formulation of the Hypothesis:
Before conducting the Jarque-Bera test, it is necessary to formulate the null and alternative hypotheses.
The null hypothesis (H0) assumes that the dataset is distributed normally. It is usually written as:
H0: The dataset is normally distributed.
The alternative hypothesis (H1) assumes that the dataset is not distributed normally. It can be either one-tailed or two-tailed and is usually written as:
H1: The dataset is not normally distributed.
In the following sections, we will provide examples of how to conduct a Jarque-Bera test in R.
What is the bias variance tradeoff? » Data Science Tutorials
Example 1: Testing Distribution 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(tseries)
Then, we can conduct the Jarque-Bera test using the ‘jarque.test’ function:
jb_test <- jarque.bera.test(mpg)
Jarque Bera Test data: mpg X-squared = 2.2412, df = 2, p-value = 0.3261
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 Distribution of Inbuilt Dataset – ‘iris’
In this example, we will use the inbuilt iris dataset to test whether the dataset is normally distributed.
First, we will load the iris dataset:
data(iris)
Next, we can extract a specific variable from the dataset:
petal_width <- iris$Petal.Width
Then, we can conduct the Jarque-Bera test using the ‘jarque.test’ function:
jarque.bera.test(petal_width) Jarque Bera Test data: petal_width X-squared = 11.416, df = 2, p-value = 0.003318
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 Petal.Width of iris dataset is not normally distributed.
Conclusion:
In this article, we have demonstrated how to conduct a Jarque-Bera test in R using inbuilt datasets.
The Jarque-Bera test is a statistical test used to determine whether a given dataset is distributed normally or not.
By utilizing the examples provided in this article, researchers can use the Jarque-Bera test to test hypotheses related to the distribution of their datasets.