q-q plot
A q-q plot is a plot of the quantiles of one dataset against the quantiles of a second dataset. This is often used to understand if the data matches the standard statistical framework, or a normal distribution.
If the data is normally distributed, the points in the q-q plot follow a straight diagonal line. This is useful to check for normality at a glance but note that it is not an accurate statistical test. In the video, you saw how to create a q-q plot using the qqnorm()
function, and how to create a reference line for if the data were perfectly normally distributed with qqline()
:
> qqnorm(amazon_stocks,
main = "AMAZON return QQ-plot")
> qqline(amazon_stocks,
col = "red")
In the context of this course, the first dataset is Apple stock return and the second dataset is a standard normal distribution. In this exercise, you will check how Apple stock returns in rtn
deviate from a normal distribution.
This exercise is part of the course
Visualizing Time Series Data in R
Exercise instructions
- Draw a q-q plot for
rtn
titled "Apple return QQ-plot" - Add a reference line in red for the normal distribution using
qqline()
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create q-q plot
# Add a red line showing normality