Descriptive Statistics

Descriptive statistics are used to summarize and describe the main features of a dataset. To demonstrate, we'll use Stata's national longitudinal study of women dataset: nlsw88.

. webuse nlsw88
(NLSW, 1988 extract)

. codebook

---------------------------------------------------------------------------------------
idcode                                                                           NLS ID
---------------------------------------------------------------------------------------

                  Type: Numeric (int)

                 Range: [1,5159]                      Units: 1
         Unique values: 2,246                     Missing .: 0/2,246

                  Mean: 2612.65
             Std. dev.: 1480.86

           Percentiles:     10%       25%       50%       75%       90%
                            521      1366      2614      3903      4651

---------------------------------------------------------------------------------------
age                                                                 Age in current year
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)

                 Range: [34,46]                       Units: 1
         Unique values: 13                        Missing .: 0/2,246

                  Mean: 39.1532
             Std. dev.:    3.06

           Percentiles:     10%       25%       50%       75%       90%
                             35        36        39        42        44

---------------------------------------------------------------------------------------
race                                                                               Race
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: racelbl

                 Range: [1,3]                         Units: 1
         Unique values: 3                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                        1,637         1  White
                          583         2  Black
                           26         3  Other

---------------------------------------------------------------------------------------
married                                                                         Married
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: marlbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                          804         0  Single
                        1,442         1  Married

---------------------------------------------------------------------------------------
never_married                                                             Never married
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: nev_mar

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                        2,012         0  Has been married
                          234         1  Never married

---------------------------------------------------------------------------------------
grade                                                           Current grade completed
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)

                 Range: [0,18]                        Units: 1
         Unique values: 16                        Missing .: 2/2,246

                  Mean: 13.0989
             Std. dev.: 2.52125

           Percentiles:     10%       25%       50%       75%       90%
                             11        12        12        15        17

---------------------------------------------------------------------------------------
collgrad                                                               College graduate
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: gradlbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                        1,714         0  Not college grad
                          532         1  College grad

---------------------------------------------------------------------------------------
south                                                                Lives in the south
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: southlbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                        1,304         0  Not south
                          942         1  South

---------------------------------------------------------------------------------------
smsa                                                                      Lives in SMSA
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: smsalbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                          665         0  Not SMSA
                        1,581         1  SMSA

---------------------------------------------------------------------------------------
c_city                                                          Lives in a central city
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: ccitylbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 0/2,246

            Tabulation: Freq.   Numeric  Label
                        1,591         0  Not central city
                          655         1  Central city

---------------------------------------------------------------------------------------
industry                                                                       Industry
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: indlbl

                 Range: [1,12]                        Units: 1
         Unique values: 12                        Missing .: 14/2,246

              Examples: 5     Transport/Comm/Utility
                        7     Finance/Ins/Real estate
                        11    Professional services
                        11    Professional services

---------------------------------------------------------------------------------------
occupation                                                                   Occupation
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: occlbl

                 Range: [1,13]                        Units: 1
         Unique values: 13                        Missing .: 9/2,246

              Examples: 2     Managers/Admin
                        3     Sales
                        4     Clerical/Unskilled
                        8     Laborers

---------------------------------------------------------------------------------------
union                                                                      Union worker
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)
                 Label: unionlbl

                 Range: [0,1]                         Units: 1
         Unique values: 2                         Missing .: 368/2,246

            Tabulation: Freq.   Numeric  Label
                        1,417         0  Nonunion
                          461         1  Union
                          368         .  

---------------------------------------------------------------------------------------
wage                                                                        Hourly wage
---------------------------------------------------------------------------------------

                  Type: Numeric (float)

                 Range: [1.0049518,40.74659]          Units: 1.000e-07
         Unique values: 967                       Missing .: 0/2,246

                  Mean: 7.76695
             Std. dev.: 5.75552

           Percentiles:     10%       25%       50%       75%       90%
                        3.22061   4.25926   6.27227   9.59742   12.7778

---------------------------------------------------------------------------------------
hours                                                                Usual hours worked
---------------------------------------------------------------------------------------

                  Type: Numeric (byte)

                 Range: [1,80]                        Units: 1
         Unique values: 62                        Missing .: 4/2,246

                  Mean: 37.2181
             Std. dev.: 10.5091

           Percentiles:     10%       25%       50%       75%       90%
                             20        35        40        40        48

---------------------------------------------------------------------------------------
ttl_exp                                                   Total work experience (years)
---------------------------------------------------------------------------------------

                  Type: Numeric (float)

                 Range: [.11538462,28.884615]         Units: 1.000e-09
         Unique values: 1,546                     Missing .: 0/2,246

                  Mean:  12.535
             Std. dev.: 4.61021

           Percentiles:     10%       25%       50%       75%       90%
                        6.01282   9.21154    13.125   15.9808   18.1538

---------------------------------------------------------------------------------------
tenure                                                               Job tenure (years)
---------------------------------------------------------------------------------------

                  Type: Numeric (float)

                 Range: [0,25.916666]                 Units: 1.000e-09
         Unique values: 259                       Missing .: 15/2,246

                  Mean: 5.97785
             Std. dev.: 5.51033

           Percentiles:     10%       25%       50%       75%       90%
                        .583333   1.58333   3.83333   9.33333     14.75

This dataset contains information on wage, occupation, demographics, and more. The tools that we will use to describe each of these variables depend on whether it is continuous or categorical. In our dataset, the variables age, grade, wage, hours, ttl_exp, and tenure are continuous and the remaining variables are categorical.

Continuous Variables

We characterize continuous variables using central tendency, dispersion, and their overall shape. We can do this visually or through summary statistics.

Summary statistics

Measures of central tendency: Measures of central tendency describe the center or typical value of a dataset. The mean is the average value, the median is the middle value when the data is ordered, and the mode is the most frequently occurring value. When a dataset is symmetric, the mean, median, and mode are all equal.

Measures of dispersion: Measures of dispersion describe the spread or variability of a dataset. The range is the difference between the maximum and minimum values, the variance is the average of the squared differences from the mean, and the standard deviation is the square root of the variance.

Measures of shape: Measures of shape describe the overall form of the distribution. Skewness measures the asymmetry of the distribution, and kurtosis measures the "tailedness" of the distribution.

We can get the mean, standard deviation, and range using the summarize command in Stata.

. summarize wage-tenure

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        wage |      2,246    7.766949    5.755523   1.004952   40.74659
       hours |      2,242    37.21811    10.50914          1         80
     ttl_exp |      2,246    12.53498    4.610208   .1153846   28.88461
      tenure |      2,231     5.97785    5.510331          0   25.91667

The average worker makes $7.77/hr, works 37.2 hours per week, has 12.5 total years of experience, and has been at their current job for almost six years.

The standard deviation of the wage variable is $5.76/hr. If this were a normal distribution, it woud indicate that we expect most workers to earn within $5.76 of the mean, or between $2.01 and $13.53.

The wage variable varies from $1.00 to $40.75, a range of $39.75, indicating a wide spread in wages across the dataset.

By adding the detail option, we can get more summary statistics. Let's take a closer look at wage.

. summarize wage, detail

                         Hourly wage
-------------------------------------------------------------
      Percentiles      Smallest
 1%     1.930993       1.004952
 5%     2.801002       1.032247
10%     3.220612       1.151368       Obs               2,246
25%     4.259257       1.344605       Sum of wgt.       2,246

50%      6.27227                      Mean           7.766949
                        Largest       Std. dev.      5.755523
75%     9.597424       40.19808
90%     12.77777       40.19808       Variance       33.12604
95%     16.52979       40.19808       Skewness       3.096199
99%     38.70926       40.74659       Kurtosis       15.85446

The median wage is $6.27/hour, less than the mean of $7.77/hour, which is consistent with a right-skewed distribution. The positive skewness of 3.1 provides further evidence of substantial right skew. The kurtosis is also high, indicating long tails.

The mode of a continuous distribution is the value that appears most frequently. Because continuous variables can take on any value within a range, we typically look at the interval with the highest frequency rather than a single value. One way we can do this in Stata is to round the wage variable into integers, and look at its tabulation table ordered from the most to least frequent.

. generate wage_r = round(wage)

. tabulate wage_r, sort

     wage_r |      Freq.     Percent        Cum.
------------+-----------------------------------
          4 |        302       13.45       13.45
          5 |        286       12.73       26.18
          3 |        264       11.75       37.93
          6 |        263       11.71       49.64
          7 |        208        9.26       58.90
          8 |        167        7.44       66.34
         10 |        151        6.72       73.06
          9 |        130        5.79       78.85
         11 |         91        4.05       82.90
         12 |         89        3.96       86.87
         13 |         52        2.32       89.18
          2 |         51        2.27       91.45
         15 |         36        1.60       93.05
         14 |         26        1.16       94.21
         17 |         19        0.85       95.06
         40 |         16        0.71       95.77
         16 |         12        0.53       96.30
         18 |         12        0.53       96.84
         39 |         11        0.49       97.33
         19 |          8        0.36       97.68
         36 |          6        0.27       97.95
          1 |          5        0.22       98.17
         21 |          5        0.22       98.40
         25 |          5        0.22       98.62
         20 |          4        0.18       98.80
         23 |          4        0.18       98.98
         26 |          3        0.13       99.11
         28 |          3        0.13       99.24
         30 |          3        0.13       99.38
         31 |          3        0.13       99.51
         32 |          3        0.13       99.64
         22 |          2        0.09       99.73
         24 |          2        0.09       99.82
         27 |          1        0.04       99.87
         29 |          1        0.04       99.91
         33 |          1        0.04       99.96
         41 |          1        0.04      100.00
------------+-----------------------------------
      Total |      2,246      100.00

The modal wage is $4-5/hr. This is the most common wage range.

Visualizations

Let's start by taking a look at the histograms of each of the continuous variables.

. foreach var of varlist wage-tenure {
  2.  histogram `var', name(`var', replace) nodraw 
  3. }
(bin=33, start=1.0049518, width=1.2042921)
(bin=33, start=1, width=2.3939394)
(bin=33, start=.11538462, width=.87179486)
(bin=33, start=0, width=.78535352)

. graph combine wage hours ttl_exp tenure
descriptive_5.svg

We can see that wage has a right-skewed distribution, hours has a mode of around 40 hours/week, ttl_exp has a left-skewed distribution and drop off shortly after 20 years, and tenure has a right-skewed distribution.

Another way to visualize the distribution of continuous variables is through box plots.

. graph box wage-tenure
descriptive_6.svg

Again, we can see that wage, and tenure are right-skewed, especially wage as we can see from the number of outliers. Work experience is left-skewed with some outliers on the high end. There are a large number of outliers on both sides of the box for hours worked.

Categorical variables

We characterize categorical variables through frequencies and percents. Again, we can do this visually and through summary statistics.

Summary statistics

We can get frequencies and percents for each category of the categorical variables with the tabulate command. To get several one-way tables at once, we can use the tab1 command with multiple variables.

. tab1 race married collgrad south smsa

-> tabulation of race  

       Race |      Freq.     Percent        Cum.
------------+-----------------------------------
      White |      1,637       72.89       72.89
      Black |        583       25.96       98.84
      Other |         26        1.16      100.00
------------+-----------------------------------
      Total |      2,246      100.00

-> tabulation of married  

    Married |      Freq.     Percent        Cum.
------------+-----------------------------------
     Single |        804       35.80       35.80
    Married |      1,442       64.20      100.00
------------+-----------------------------------
      Total |      2,246      100.00

-> tabulation of collgrad  

College graduate |      Freq.     Percent        Cum.
-----------------+-----------------------------------
Not college grad |      1,714       76.31       76.31
    College grad |        532       23.69      100.00
-----------------+-----------------------------------
           Total |      2,246      100.00

-> tabulation of south  

   Lives in |
  the south |      Freq.     Percent        Cum.
------------+-----------------------------------
  Not south |      1,304       58.06       58.06
      South |        942       41.94      100.00
------------+-----------------------------------
      Total |      2,246      100.00

-> tabulation of smsa  

   Lives in |
       SMSA |      Freq.     Percent        Cum.
------------+-----------------------------------
   Not SMSA |        665       29.61       29.61
       SMSA |      1,581       70.39      100.00
------------+-----------------------------------
      Total |      2,246      100.00

Most of the workers in our dataset are White, married, without a college degree, don't live in the south, but do live in a metropolitan area.

Visualizations

We typically use a bar graph to visualize categories of categorical variables.

. graph bar (count), over(race)
descriptive_8.svg

Again, we see that the majority of workers are White, followed by Black, with very few people from other races.