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