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.

How to Conduct a Jarque-Bera Test in R

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

Similar Reads

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....

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....

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....

Contact Us