How to Create & Interpret a Q-Q Plot in R - Statology (2024)

AQ-Q plot, short for “quantile-quantile” plot, is a type of plot that we can use to determine whether or not a set of data potentially came from some theoretical distribution.

Many statistical tests make the assumption that a set of data follows a normal distribution, and a Q-Q plot is often used to assess whether or not this assumption is met.

Although a Q-Q plot isn’t a formal statistical test, it does provide an easy way to visually check whether a dataset follows a normal distribution, and if not, how this assumption is violated and which data points potentially cause this violation.

We can create a Q-Q plot by plotting two sets of quantiles against one another. If both sets of quantiles came from the same distribution, then the points on the plot should roughly form a straight diagonal line.

How to Create & Interpret a Q-Q Plot in R - Statology (1)

Quantilesrepresent points in a dataset below which a certain portion of the data fall. For example, the 0.9 quantile represents the point below which 90% of the data fall below. The 0.5 quantile represents the point below which 50% of the data fall below, and so on.

Q-Q plots identify the quantiles in your sample data and plot them against the quantiles of a theoretical distribution. In most cases the normal distribution is used, but a Q-Q plot can actually be created for any theoretical distribution.

If the data points fall along a straight diagonal line in a Q-Q plot, then the dataset likely follows a normal distribution.

How to Create a Q-Q Plot in R

We can easily create a Q-Q plot to check if a dataset follows a normal distribution by using the built-inqqnorm()function.

For example, the following code generates a vector of 100 random values that follow a normal distribution and creates a Q-Q plot for this dataset to verify that it does indeed follow a normal distribution:

#make this example reproducibleset.seed(11)#generate vector of 100 values that follows a normal distributiondata <- rnorm(100)#create Q-Q plot to compare this dataset to a theoretical normal distributionqqnorm(data)

How to Create & Interpret a Q-Q Plot in R - Statology (2)

To make it even easier to see if the data falls along a straight line, we can use theqqline()function:

#create Q-Q plotqqnorm(data)#add straight diagonal line to plotqqline(data)

How to Create & Interpret a Q-Q Plot in R - Statology (3)

We can see that the data points near the tails don’t fall exactly along the straight line, but for the most part this sample data appears to be normally distributed (as it should be since we told R to generate the data from a normal distribution).

Consider instead the following code that generates a vector of 100 random values that follow a gamma distribution and creates a Q-Q plot for this data to check if it follows a normal distribution:

#make this example reproducibleset.seed(11)#generate vector of 100 values that follows a gamma distributiondata <- rgamma(100, 1)#create Q-Q plot to compare this dataset to a theoretical normal distributionqqnorm(data)qqline(data)

How to Create & Interpret a Q-Q Plot in R - Statology (4)

We can see the clear departure from the straight line in this Q-Q plot, indicating that this dataset likely does not follow a normal distribution.

Consider another chunk of code that generates a vector of 100 random values that follow a Chi-Square distribution with 5 degrees of freedom and creates a Q-Q plot for this data to check if it follows a normal distribution:

#make this example reproducibleset.seed(11)#generate vector of 100 values that follows a Chi-Square distributiondata <- rchisq(100, 5)#create Q-Q plot to compare this dataset to a theoretical normal distributionqqnorm(data)qqline(data)

How to Create & Interpret a Q-Q Plot in R - Statology (5)

Once again we can see that this dataset does not appear to follow a normal distribution, especially near the tails.

Modifying the Aesthetics of a Q-Q Plot in R

We can modify some of the aesthetics of the Q-Q plot in R including the title, axis labels, data point colors, line color, and line width.

The following code modifies the titles, axis labels, and color of the points in the plot:

#make this example reproducibleset.seed(11)#generate vector of 100 values that follows a normal distributiondata <- rnorm(100)#create Q-Q plotqqnorm(data, main = 'Q-Q Plot for Normality', xlab = 'Theoretical Dist', ylab = 'Sample dist', col = 'steelblue')

How to Create & Interpret a Q-Q Plot in R - Statology (6)

Next, the following code adds a straight diagonal line to the plot with a color of red, a line width of 2 (lwd = 2, default is 1), and a dashed line (lty = 2, default is 1):

qqline(data, col = 'red', lwd = 2, lty = 2)

How to Create & Interpret a Q-Q Plot in R - Statology (7)

Technical Notes

Keep in mind that a Q-Q plot is simply a way tovisuallycheck if a dataset follows a theoretical distribution. To formally test whether or not a dataset follows a particular distribution, the following tests can be performed (assuming you’re comparing your dataset to a normal distribution):

Anderson-Darling Test
Shapiro-Wilk Test
Kolmogorov-Smirnov Test

How to Create & Interpret a Q-Q Plot in R - Statology (2024)

FAQs

How to interpret Q-Q plot in R? ›

On the horizontal axis, it shows the expected value of an individual with the same quantile if the distribution were normal (“theoretical quantiles” in the same figure). The QQ plot should follow more or less along a straight line if the data come from a normal distribution (with some tolerance for sampling variation).

How to check normality with Q-Q plot in R? ›

If the points in the Q-Q plot are on a line from the lower left to the upper right then the data is basically normally distributed. Try playing with different sets of data and Equations in this online tool to see the impact on the Q-Q Plots.

How do you interpret a Q-Q plot for a normal distribution? ›

Normally distributed data

The normal distribution is symmetric, so it has no skew (the mean is equal to the median). On a Q-Q plot normally distributed data appears as roughly a straight line (although the ends of the Q-Q plot often start to deviate from the straight line).

How to create a Q-Q plot in R? ›

In R, there are two functions to create QQ plots: qqnorm() and qqplot() . qqnorm() creates a normal QQ plot. You give it a vector of data, and R plots the data in sorted order versus quantiles from a standard normal distribution. For example, consider the trees data set that comes with R.

What is a Q-Q plot for dummies? ›

A q-q plot is a plot of the quantiles of the first data set against the quantiles of the second data set. By a quantile, we mean the fraction (or percent) of points below the given value. That is, the 0.3 (or 30%) quantile is the point at which 30% percent of the data fall below and 70% fall above that value.

What does qqline do in R? ›

qqline adds a line to a “theoretical”, by default normal, quantile-quantile plot which passes through the probs quantiles, by default the first and third quartiles. qqplot produces a QQ plot of two datasets. Graphical parameters may be given as arguments to qqnorm , qqplot and qqline .

What are the points on a Q-Q plot? ›

A point (x, y) on the plot corresponds to one of the quantiles of the second distribution (y-coordinate) plotted against the same quantile of the first distribution (x-coordinate). This defines a parametric curve where the parameter is the index of the quantile interval.

How to interpret a Q-Q plot in a linear regression model? ›

To interpret a Q-Q plot, you need to look at the shape and pattern of the points. If the points lie on or close to a 45-degree line, it means that the data follow the reference distribution closely.

How do you know if a Q-Q plot is right skewed? ›

If the bottom end of the Q-Q plot deviates from the straight line but the upper end is not, then the distribution is Left skewed(Negatively skewed). Now if upper end of the Q-Q plot deviates from the staright line and the lower is not, then the distribution is Right skewed(Positively skewed).

What should a detrended normal Q-Q plot look like? ›

The detrended normal Q-Q plot on the right shows a horizontal line representing what would be expected for that value if the data sere normally distributed. Any values below or above represent what how much lower or higher the value is, respectively, than what would be expected if the data were normally distributed.

How to tell if data is normally distributed? ›

A histogram is an effective way to tell if a frequency distribution appears to have a normal distribution. Plot a histogram and look at the shape of the bars. If the bars roughly follow a symmetrical bell or hill shape, like the example below, then the distribution is approximately normally distributed.

What is the Q-Q plot function in R? ›

The qqPlot function is a modified version of the R functions qqnorm and qqplot . The EnvStats function qqPlot allows the user to specify a number of different distributions in addition to the normal distribution, and to optionally estimate the distribution parameters of the fitted distribution.

What is the Z score of the Q-Q plot? ›

When the option Q-Q plot is selected, the horizontal axis shows the z-scores of the observed values, z=(x−mean)/SD. A straight reference line represents the Normal distribution. If the sample data are near a Normal distribution, the data points will be near this straight line.

What does a heavy-tailed Q-Q plot mean? ›

Heavy tailed qqplot: meaning that compared to the normal distribution there is much more data located at the extremes of the distribution and less data in the center of the distribution.

How to interpret a detrended normal Q-Q plot? ›

The detrended normal Q-Q plot on the right shows a horizontal line representing what would be expected for that value if the data sere normally distributed. Any values below or above represent what how much lower or higher the value is, respectively, than what would be expected if the data were normally distributed.

Top Articles
10 Types of Information Technologies Used in Supply Chain or Logistics
S&OP Planning Manager Job Description
Hometown Pizza Sheridan Menu
Antisis City/Antisis City Gym
Frases para un bendecido domingo: llena tu día con palabras de gratitud y esperanza - Blogfrases
Kathleen Hixson Leaked
Body Rubs Austin Texas
Kentucky Downs Entries Today
Corporate Homepage | Publix Super Markets
Day Octopus | Hawaii Marine Life
Danielle Longet
Ukraine-Russia war: Latest updates
Hmr Properties
8 Ways to Make a Friend Feel Special on Valentine's Day
Chicken Coop Havelock Nc
Colts Snap Counts
Arre St Wv Srj
Is Grande Internet Down In My Area
Prestige Home Designs By American Furniture Galleries
The best TV and film to watch this week - A Very Royal Scandal to Tulsa King
Virginia New Year's Millionaire Raffle 2022
Ratchet & Clank Future: Tools of Destruction
Epguides Strange New Worlds
Melendez Imports Menu
Southland Goldendoodles
3569 Vineyard Ave NE, Grand Rapids, MI 49525 - MLS 24048144 - Coldwell Banker
Black Panther 2 Showtimes Near Epic Theatres Of Palm Coast
Chelsea Hardie Leaked
Tim Steele Taylorsville Nc
Select The Best Reagents For The Reaction Below.
Mchoul Funeral Home Of Fishkill Inc. Services
49S Results Coral
ATM, 3813 N Woodlawn Blvd, Wichita, KS 67220, US - MapQuest
Mia Malkova Bio, Net Worth, Age & More - Magzica
Jambus - Definition, Beispiele, Merkmale, Wirkung
Craigslist Dallastx
Wednesday Morning Gifs
John F Slater Funeral Home Brentwood
Reading Craigslist Pa
R&J Travel And Tours Calendar
D3 Boards
ATM Near Me | Find The Nearest ATM Location | ATM Locator NL
My.lifeway.come/Redeem
Merkantilismus – Staatslexikon
SF bay area cars & trucks "chevrolet 50" - craigslist
Ferguson Showroom West Chester Pa
Weather In Allentown-Bethlehem-Easton Metropolitan Area 10 Days
21 Alive Weather Team
Powerspec G512
Lawrence E. Moon Funeral Home | Flint, Michigan
Dicks Mear Me
Costner-Maloy Funeral Home Obituaries
Latest Posts
Article information

Author: Otha Schamberger

Last Updated:

Views: 5983

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Otha Schamberger

Birthday: 1999-08-15

Address: Suite 490 606 Hammes Ferry, Carterhaven, IL 62290

Phone: +8557035444877

Job: Forward IT Agent

Hobby: Fishing, Flying, Jewelry making, Digital arts, Sand art, Parkour, tabletop games

Introduction: My name is Otha Schamberger, I am a vast, good, healthy, cheerful, energetic, gorgeous, magnificent person who loves writing and wants to share my knowledge and understanding with you.