Histogram

Quick facts

Number of variables
One

Scales of variable(s)
Continuous

Information

A histogram is similar to a bar chart but, unlike the bar chart, it is suitable for continuous variables.

The histogram will give us an idea about whether the distribution (of the continuous variable) is normal or skewed.

It is also possible to include a normal curve in the chart in order to see how the data adheres to a normal distribution.

Function

Basic command
histogram varname, freq
Useful options
histogram varname, freq norm
histogram varname, freq norm bin(x)
histogram varname, freq norm d
Explanations
varnameInsert the name of the variable.
freqShow frequencies on the y-axis.
normInclude a normal curve in the histogram.
bin(x)Here you can specify how many bins you want to histogram to show; might require some experimenting.
dSpecify that data are discrete.
Short names
freqfrequencies
normnormal
ddiscrete
More information
help histogram

Practical example

Dataset
StataData1.dta
Variable namecognitive
Variable labelCognitive test score (Age 15, Year 1985)
Value labelsN/A
histogram cognitive

This is a histogram of cognitive.

The default is that the y-axis shows the density of values across the x-axis. Moreover, by default, the bins might represent intervals of values (thus, one bin does not necessarily represent one single value) – this depends on the range of values of the variable.

In this example, we can see that the variable is approximately normally distributed (with a slight negative skew).

We can revise our histogram to display frequency on the y-axis instead of density. Moreover, we can specify that the values are discrete, in order to display one bin per value. And finally, we can add a normal curve on top of our histogram.

histogram cognitive, freq norm d

Note
You can use the Graph Editor (see Graph) to edit the histogram.