2.5 Examining Distributions

Meme of Moses holding stone tablets: 'Look at your data!'

Frequency tables & bar charts

  • For a nominal/binary IV, can just look at frequency (or %) in each category
use "https://tdmize.github.io/data/data/gss", clear
(gss.dta | GSS 1972 - 2016 Data | DMV Workshop)
fre degree if year >= 2010
degree -- Highest Educ Degree
-----------------------------------------------------------------------
                          |      Freq.    Percent      Valid       Cum.
--------------------------+--------------------------------------------
Valid   0  lt high school |       1251      13.28      13.29      13.29
        1  high school    |       4707      49.95      49.99      63.28
        2  junior college |        698       7.41       7.41      70.70
        3  bachelor       |       1737      18.43      18.45      89.14
        4  graduate       |       1022      10.85      10.86     100.00
        Total             |       9415      99.92     100.00           
Missing .n NA             |          8       0.08                      
Total                     |       9423     100.00                      
-----------------------------------------------------------------------

Stata: I much prefer the fre command to tabulate, as you get: numeric value, value label, frequency counts, percents, and missing data all shown by default.

R: I like the frq() function from library(sjmisc).

graph hbar if year >= 2010, over(degree) ///
    title("[2.5.a] Distribution of educational attainment: GSS 2000 - 2016") /
//
    ytitle("% of sample with this degree")

Horizontal bar chart of the percentage of respondents with each educational degree; high school is the largest category.

Tools for examining distributions

  • Histograms are a good first step for continuous variables
    • Separate “bins” for ranges of continuous variables (e.g., age 20-25, 26-30, 31-35, 36-40, etc.)
  • Kernel density plots are helpful to examine a smoothed version of the distribution (rather than each specific bin as with a histogram)
    • Kernel density plots are also helpful to overlay plots across multiple groups
  • See examples below
hist wages, percent fcol(none) ///
    title("[2.5.b] Distribution of Hourly Wages")
(bin=44, start=.10516854, width=1.5885189)

Histogram of hourly wages, strongly skewed to the right.

twoway kdensity wages, ///
    title("[2.5.c] Distribution of Hourly Wages") ///
    xtitle("Hourly Wages")

Kernel density plot of hourly wages, peaking near 10 dollars with a long right tail.

twoway kdensity wages if woman == 0 || ///
    kdensity wages if woman == 1 ||, ///
    title("[2.5.d] Distribution of Hourly Wages for Men and Women") ///
    xtitle("Hourly Wages") legend(order(1 "Men" 2 "Women"))

Kernel density plots of hourly wages for men and women; women's wages are more concentrated at lower values.

Back to top