Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generating a quantile-quantile plot (QQ plot)


QQ plots are mainly used in academic literature to test for normality. R comes with some basic methods to test for normality, such as the Shapiro test. The Jarque-Bera test is another such normality test that is available with the tseries package. Many times, we are interested in understanding how much our data deviates from a normally distributed data.

One of the hot topics in finance is the study of fat tails in stock markets. Researchers have observed that equity prices or stock returns do not have a normal distribution and the actual distribution of returns contains fat tails.

Getting ready

We need to install and load the quantmod package to download the historical prices of Microsoft:

install.packages("quantmod")
library(quantmod)

How to do it…

We are familiar with the getSymbols() function to load the data in R. All of the functions used previously have been discussed in detail under the recipe Generating a candlestick plot:

prices = c("MSFT"...