Open In App

How to Conduct a Jarque-Bera Test in R

Last Updated : 19 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss What is the Jarque-Bera Test and how we perform the Jarque-Bera Test in R Programming Language.

What is the Jarque-Bera Test?

The Jarque-Bera test is a statistical test used to assess whether a given dataset follows a normal distribution based on its skewness and kurtosis. Its purpose is to determine if the data conforms to the assumptions of many statistical techniques that rely on the normality assumption, such as linear regression and t-tests. By testing for normality, the Jarque-Bera test helps ensure the validity of statistical analyses and the reliability of their results.

  • Null Hypothesis (H0): The data is normally distributed.
  • Alternative Hypothesis (H1): The data is not normally distributed.

After conducting the test, you will typically obtain a test statistic and its associated p-value. Here’s how to interpret the results:

  • If the p-value is less than the chosen significance level (e.g., 0.05)
    • Reject the null hypothesis.
    • Conclude that the data are not normally distributed.
  • If the p-value is greater than or equal to the significance level
    • Fail to reject the null hypothesis.
    • Conclude that there is not enough evidence to suggest that the data are not normally distributed.

A larger test statistic indicates a greater departure from normality.

  • If p-value < significance level: Reject H0, conclude data are not normally distributed.
  • If p-value ≥ significance level: Fail to reject H0, conclude there’s not enough evidence to suggest data are not normally distributed.

The test statistic for the Jarque-Bera test is computed based on the skewness and kurtosis of the dataset. Specifically, it uses the following formula:

[Tex]JB = \frac{n}{6} \left( S^2 + \frac{1}{4}(K – 3)^2 \right) [/Tex]

Where:

  • n is the sample size.
  • S is the skewness of the data.
  • K is the kurtosis of the data.

Under the null hypothesis of normality, the test statistic JB asymptotically follows a chi-square distribution with two degrees of freedom (because there are two parameters estimated from the sample data: skewness and kurtosis).

To conduct the Jarque-Bera test, we compare the computed test statistic with the critical value from the chi-square distribution at a chosen significance level. If the test statistic is greater than the critical value, then we reject the null hypothesis, indicating that the data is not normally distributed.

Preparing the data properly before conducting the test

  1. Accuracy of Results: Preparing the data properly helps ensure that the data accurately reflects the underlying phenomenon being studied. This includes verifying the correctness of data entries, addressing missing or erroneous values, and checking for outliers or anomalies.
  2. Assumption of Normality: The Jarque-Bera test assumes that the data are drawn from a normal distribution. Therefore, it’s essential to confirm that this assumption holds true before conducting the test. Data preparation may involve transforming the data or identifying and addressing any violations of normality assumptions.
  3. Quality of Inferences: The conclusions drawn from the Jarque-Bera test can influence subsequent analyses or decisions. Proper data preparation helps mitigate potential biases or errors in these inferences, ensuring that they are accurate and reliable.
  4. Validity of Statistical Analyses: Many statistical methods and models rely on the normality assumption. If the data violate this assumption, the results of subsequent analyses may be invalid or misleading. Proper data preparation helps ensure that the data conform to the assumptions required by the statistical techniques being applied.
  5. Robustness of Findings: Well-prepared data contribute to the robustness of research findings. By addressing potential issues in the data before conducting the Jarque-Bera test, researchers can have greater confidence in the reliability and generalizability of their results.

Jarque-Bera Test in R

To perform Jarque-Bera Test in R there are a function called jarque.bera.test() . There are some steps that we need to follow.

Step 1: Load the Required Package

Firstly install and load the tseries package. Install it using install.packages(“tseries”) and then load it using library(tseries).

Step 2 : Prepare the Data

Ensure that the data is properly prepared and stored in a format that R can recognize. This may involve loading a dataset from a file or creating a vector or matrix of data within R.

Step 3: Call the Function

Use the jarque.bera.test() function, passing the data as an argument.

Here is the example tseries library, which contains the jarque.bera.test() function.

R

# Load required library library(tseries) # Generate some random data data <- rnorm(100) # Perform the Jarque-Bera test jb_test <- jarque.bera.test(data) # Print the test result print(jb_test)

Output:

Jarque Bera Test data: data X-squared = 0.013514, df = 2, p-value = 0.9933

Firstly load the tseries library, which contains the jarque.bera.test() function for performing the Jarque-Bera test.

  • It generates a vector of 100 random numbers from a standard normal distribution using rnorm(100).
  • The Jarque-Bera test is then applied to the generated data using jarque.bera.test(data).
  • The result of the test is stored in the variable jb_test.
  • Finally, the test result is printed using print(jb_test), which displays the test statistic and the p-value.
  • The Jarque-Bera test was performed on the given data.
  • The test statistic (X-squared) is 0.013514.
  • The degrees of freedom (df) is 2.
  • The p-value associated with the test is 0.9933.

Since the p-value is greater than the common significance levels (e.g., 0.05), we fail to reject the null hypothesis of normality. This suggests that there is no strong evidence to suggest that the data significantly deviates from a normal distribution.

Jarque-Bera test using the moments package in R

Here is another example of performing the Jarque-Bera test using the moments package in R.

R

# Install and load required library install.packages("moments") library(moments) # Generate some random data data <- rnorm(100) # Perform the Jarque-Bera test jb_test <- jarque.test(data) # Print the test result print(jb_test)

Output:

Jarque-Bera Normality Test data: data JB = 0.45895, p-value = 0.795 alternative hypothesis: greater

First install and load the moments package which contains the jarque.test() function.

  • Random data is generated using the rnorm() function, which creates a vector of random numbers from a normal distribution.
  • The Jarque-Bera test is applied to the generated data using jarque.test(data).
  • The result of the test is stored in the variable jb_test.
  • Finally, the test result is printed, showing the test statistic, p-value, skewness, and kurtosis.

Jarque-Bera statistic: This is the test statistic for the Jarque-Bera test. It quantifies the departure of the sample skewness and kurtosis from the skewness and kurtosis of a normal distribution. Here, the JB statistic is 0.15467.

  • p-value: The p-value indicates the probability of observing a test statistic as extreme as, or more extreme than, the one calculated from the sample data under the assumption that the null hypothesis is true. A higher p-value, such as 0.9256 in this case, suggests weak evidence against the null hypothesis. It means that there is no strong evidence to reject the null hypothesis that the data comes from a normal distribution.
  • Alternative hypothesis: In this case, the alternative hypothesis is specified as “greater”, which means that the test is one-tailed, and the alternative hypothesis is that the data are greater than expected under a normal distribution.

Uses of the Jarque-Bera Test in R

  1. Normality Check: JB test assesses whether data follows a normal distribution.
  2. Quality Control: Used in finance, economics, and other fields to detect anomalies in data.
  3. Model Validation: Ensures that statistical models meet the assumption of normality for accurate results.
  4. Robustness Checks: Part of sensitivity analysis to verify the robustness of research findings.
  5. Guide for Analysis: Helps decide between parametric and non-parametric methods based on data distribution.
  6. Data Preprocessing: Guides preprocessing steps like data transformations for better analysis.

Conclusion

The Jarque-Bera (JB) test is a critical statistical tool used to evaluate the normality assumption of a dataset. By examining skewness and kurtosis, the JB test provides insights into the distributional properties of the data. This test holds significance across various domains, including finance, economics, and research, serving as a quality control measure to detect anomalies and irregularities in data.Overall, it ensures the reliability of research findings.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads