Skip to content

Normality in Error Term: Q-Q Plot and Jarque-Bera Test in R Video

Last Update: March 22, 2022

My online video tutorials are hosted at YouTube channel.

For learning this concept, you can view my online video tutorial: Normality in Error Term: Q-Q Plot and Jarque-Bera Test in R.

Video Code

1. Packages

library(AER)
library(ggplot2)
library(tseries)

2. Data

data(HousePrices)

3. Model

mlr <- lm(formula = price ~ lotsize + bedrooms, data = HousePrices)

4. Normality

resid <- mlr$residuals

Q-Q Plot

ggplot(data = data.frame(resid), aes(sample = resid)) +
  stat_qq(distribution = qnorm) +
  stat_qq_line(distribution = qnorm, color = "red") +
  labs(title = "Normal Q-Q Plot", x = "Theoretical Quantiles", 
       y = "Sample Quantiles")

Jarque-Bera Test

jarque.bera.test(x = resid)

Courses

My online courses are hosted at Teachable website.

For more details on this concept, you can view my Linear Regression in R Course.

My online courses are closed for enrollment.
+