In this lab, you’ll investigate the probability distribution that is most central to statistics: the normal distribution. If you are confident that your data are nearly normal, that opens the door to many powerful statistical methods. Here we’ll use the graphical tools of jamovi to assess the normality of our data and also learn how to generate random numbers from a normal distribution. We’ll also discover a little about R, the language jamovi is built on.

Getting Started

Load module

In this lab, we will use the distrACTION module in jamovi, which contains information on distributions. Click the plus button at the top right part of the screen, and add the distrACTION module to jamovi. When you do this, you will see a new icon in the top bar.

The data

This week you’ll be working with fast food data. This data set contains data on 515 menu items from some of the most popular fast food restaurants worldwide, and you can load it from here. Let’s take a quick peek at the first few rows of the data.

You’ll see that for every observation there are 17 measurements, many of which are nutritional facts.

You’ll be focusing on just three columns to get started: restaurant, calories, calories from fat.

Let’s first focus on just products from McDonalds and Dairy Queen.

  1. Make a plot (or plots) to visualize the distributions of the amount of calories from fat of the options from each of these two restaurants. How do their centers, shapes, and spreads compare? Hint: There are many ways to do this. One way would be to apply a filter to only include McDonals’ foods, and create your plots and find descriptive statistics. Then you could apply a filter to only include Dairy Queen. Alternatively, you could apply a filter to include only McDonald’s and Dairy Queen, then split by restaurant to do this in one step. To create a filter for a categorical variable, you can use the filter menu like we have done before, or click the name of the variable to click levels of the variable to include them or not include them (using the check marks and X’s in the left column).

The normal distribution

In your description of the distributions, did you use words like bell-shaped or normal? It’s tempting to say so when faced with a unimodal symmetric distribution.

To see how accurate that description is, you can plot a normal distribution curve on top of a histogram to see how closely the data follow a normal distribution. This normal curve should have the same mean and standard deviation as the data.

You’ll be focusing on calories from fat from Dairy Queen products, so let’s first filter out everything except for those products.

Evaluating the normal distribution

Eyeballing the shape of the histogram is one way to determine if the data appear to be nearly normally distributed, but it can be frustrating to decide just how close the histogram is to the curve. An alternative approach involves constructing a normal probability plot, also called a normal Q-Q plot for “quantile-quantile”.

Again within the Exploration section, open the plots menu and check the Q-Q box to have jamovi generate the Q-Q plot for this data.

The x-axis values correspond to the quantiles of a theoretically normal curve with mean 0 and standard deviation 1 (i.e., the standard normal distribution). The y-axis values correspond to the quantiles of the original unstandardized sample data. However, even if we were to standardize the sample data values, the Q-Q plot would look identical. A data set that is nearly normal will result in a probability plot where the points closely follow a diagonal line. Any deviations from normality leads to deviations of these points from that line.

The plot for Dairy Queen’s calories from fat shows points that tend to follow the line but with some errant points towards the upper tail. You’re left with the same problem that we encountered with the histogram above: how close is close enough?

A useful way to address this question is to rephrase it as: what do probability plots look like for data that I know came from a normal distribution?

We can answer this by simulating data from a normal distribution. Make a note of the mean and standard deviation from our cal_fat variable - we’re going to need them. We can make a new variable with the same mean and standard deviation which does come from a normal distribution. To do this, make a new variable called sim_norm using the “New Computed Variable” option. For the formula, click the \(f_x\) menu, then scroll down to the bottom. NORM will sample from a normal distribution. Enter the mean and standard deviation in parentheses after NORM with a comma between them.

  1. Make a normal probability plot (Q-Q plot) of sim_norm variable. Do all of the points fall on the line? How does this plot compare to the probability plot for the real data?

Even better than comparing the original plot to a single plot generated from a normal distribution is to compare it to more plots. Using the same method, create sim_norm2, sim_norm3, and so on, until you have a collection of variables which are all normally distributed.

  1. Does the normal probability plot for the calories from fat look similar to the plots created for the simulated data? That is, do the plots provide evidence that the calories from fat are nearly normal?

  2. Using the same technique, determine whether or not the calories from McDonald’s menu appear to come from a normal distribution.

Normal probabilities

Okay, so now you have a slew of tools to judge whether or not a variable is normally distributed. Why should you care?

It turns out that statisticians know a lot about the normal distribution. Once you decide that a random variable is approximately normal, you can answer all sorts of questions about that variable related to probability. Take, for example, the question of, “What is the probability that a randomly chosen Dairy Queen product has more than 600 calories from fat?”

If we assume that the calories from fat from Dairy Queen’s menu are normally distributed (a very close approximation is also okay), we can find this probability by calculating a Z score and consulting a Z table (also called a normal probability table). In jamovi, this is done in the Compute probability section of the Normal menu. Within this menu, make sure the mean and standard deviation are correct, then check the Compute probability box. Select the third button and set x1 to 0 and x2 to 600.

Assuming a normal distribution has allowed us to calculate a theoretical probability. If we want to calculate the probability empirically, we need to determine how many observations fall above 600. We could do this by creating a new variable which is 0 or 1 depending on whether cal_fat is greater than 600, then take the mean of this column.

Although the probabilities are not exactly the same, they are reasonably close. The closer that your distribution is to being normal, the more accurate the theoretical probabilities will be.

  1. Write out two probability questions that you would like to answer about any of the restaurants in this dataset. Calculate those probabilities using both the theoretical normal distribution as well as the empirical distribution (four probabilities in all). Which one had a closer agreement between the two methods?

More Practice

  1. Now let’s consider some of the other variables in the dataset. Out of all the different restaurants, which ones’ distribution is the closest to normal for sodium?

  2. Note that some of the normal probability plots for sodium distributions seem to have a stepwise pattern. Why do you think this might be the case?

  3. As you can see, normal probability plots can be used both to assess normality and visualize skewness. Make a normal probability plot for the total carbohydrates from a restaurant of your choice. Based on this normal probability plot, is this variable left skewed, symmetric, or right skewed?
    Use a histogram to confirm your findings.


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.