CMSE11624 Statistics for Analytics

Session 2: Descriptive and Summary Statistics

Dr Zexun Chen

Table of Contents

Motivated Examples

Data Process

image

Raw Data

Descriptive statistics are the tabular, graphical, and numerical methods used to summarise data.

Here is a dataset, total income of a borrower (total income) and the amount they borrowed (loan amount) for the loan50 data set.

Total Income and Loan Amount
Index Total Income ($) Loan Amount ($)
0 59000 22000
1 60000 6000
2 75000 25000
3 75000 6000
4 254000 25000
5 67000 6400
6 28800 3000
7 80000 14500
8 34000 10000
9 192000 18500

Summarising Data in Statistics

Summary Statistics
Variable Total Income ($) Loan Amount ($)
Mean 105,220.56 17,083.00
Median 78,750.0 15,500.0
Std Deviation 68,141.97 10,455.46
Variance 4,643,328,000.0 109,316,600.0
Mode 34,000.0 6,000.0
25th Percentile 60,000.0 7,125.0
75th Percentile 119,000.0 24,000.0

Summarising Data in Graph

image

Important Statistical Concepts

Sample vs Population

image

For example, we might want to know the mean weight of a certain species of turtle that has a total population of 800.

Statistic vs Parameter

In statistical jargon, we would say that the sample mean is a statistic while the population mean is a parameter.

  • A statistic is a number that describes some characteristics of a sample.

  • A parameter is a number that describes some characteristics of a population.

The parameter is the value that we’re actually interested in measuring, but the statistic is the value that we use to estimate the value of the parameter since the statistic is so much easier to obtain.

For example, it is impossible to get all turtles in the park, thus it is impossible to get their weights! We can only get, an average of 30 turtles’ weights and use it (statistic) to estimate the average weight (parameter) of ALL turtles.

Descriptive vs Inferential

Statistics performs two main tasks. Its goal is either

  • to describe something that has already happened or already exists (descriptive statistics),

  • or to estimate something that has not happened yet or is not fully known (inferential statistics).

  • Descriptive statistics deals with the problem of how to effectively look at data we already have.

  • Inferential statistics (the estimating and forecasting part of statistics) deals with the problem of not having all the data.

Definitely, inferential statistics is the one that is much more interesting and much more frequently used in finance and investing. The primary task of inferential statistics (or estimating or forecasting) is making an opinion about something by using only an incomplete sample of data.

Descriptive Statistics

Numerical measures

  • Measures of Location / Central Tendency

  • Measures of Variability / Dispersion

  • Measure of both, e.g. Shape/ Skewness

Measures of Location: Mean

image

Measures of Location: Mode

  • The mode of a data set is the value that occurs with the (local) greatest frequency.

  • The greatest frequency can occur at two or more different values.

  • If the data have exactly two modes, the data are bimodal.

  • If the data have more than two modes, the data are multimodal.

image

Measures of Location: Median

  • The median of a data set is the value in the middle when the data items are arranged in ascending order.

  • Whenever a data set has extreme values, the median is the preferred measure of central location.

  • The median is the measure of location most often reported for annual income and property value data.

  • A few extremely large incomes or property values can inflate the mean.

image

Measures of Location: Median

Measures of Location: Percentiles

  • A percentile provides information about how the data are spread over the interval from the smallest value to the largest value.

  • The \(p\)th percentile of a data set is a value such that at least p percent of the items take on this value or less and at least (100 - \(p\)) percent of the items take on this value or more.

Measures of Location: Quartiles

  • Quartiles are specific percentiles.

  • First Quartile Q1 = 25th Percentile

  • Second Quartile Q2 = 50th Percentile = Median

  • Third Quartile Q3= 75th Percentile

Measures of Variability

  • Variance

  • Standard Deviation

  • Range

  • Interquartile Range = IQR

Measures of Variability: Variance & Standard Deviation

  • The variance is the average of the squared differences between each data value and the mean. Standard Deviation is the square root of variance.

  • image
  • The sample mean is an unbiased estimator of the population mean.

  • The sample variance SHOULD BE an unbiased estimator of the population variance. \[\mathbb{E}(s^2) = \sigma^2\]

Measures of Variability: Variance & Standard Deviation

image

Measures of Variability: Range & IQR

  • Range = Largest - Smallest

  • IQR = Q3 - Q1

image

Measures of Variability: Outliers

  • An outlier is an unusually small or unusually large value in a data set.

  • A data value that is more than 3 standard deviations away from the mean might be considered an outlier, OR outside the range \[(Q1 - 1.5*IQR, Q3+ 1.5* IQR)\]

  • But the definition of "outlier" usually depends on the real problems!

  • It might be:

    • an incorrectly recorded data value

    • a data value that was incorrectly included in the data set

    • a correctly recorded data value that belongs to another dataset.

Measures of Both: Skewness

The skewness (3rd moment) is a measure of the asymmetry of the distribution. The skewness \(\gamma_1\) of a random variable X is the third standardised moment \(\tilde {\mu }_{3}\), defined as \[\gamma_1 : \tilde{\mu_3} = \mathbb{E}[\frac{X - \mu}{\sigma}] = \frac{\mu_3}{\sigma^3} = \frac{\mathbb{E}[(X- \mu)^3]}{(\mathbb{E}[(X-\mu)^2])^{3/2}}\]

image

  • Positive skewed = right skewed

  • Negative skewed = left skewed

Measures of Both: Skewness

In risk measurement, it tells us whether the probability of winning is similar to the probability of losing and the nature of losses (assuming the distributions below are loss distribution ).

  • Negative skewness means that there is a substantial probability of a big negative return.

  • Positive skewness means that there is a greater-than-normal probability of a big positive return.

  • Simpler definition (Pearson median skewness or second skewness coefficient) \[\gamma_2 = \frac{3 (mean - median)}{\sigma}\]

image

Statistical Graphs

Graphs

  • Line Chart

  • Scatter Plot (Dot Plot)

  • Bar plot

  • Pie plot

  • Boxplot

  • Histogram / Density

  • Mosaic Plot

  • Violin plot / Pirate plot

  • ...

Example: Hudson Auto Repair

The manager of Hudson Auto would like to have a better understanding of the cost of parts used in the engine tune-ups performed in the shop. She examines 50 customer invoices for tune-ups. The costs of parts, rounded to the nearest £:

image

Sample of Parts Cost for 50 Tune-ups (£)
91 78 93 57 75 52 99 80 97 62
71 69 72 89 66 75 79 75 72 76
104 74 62 68 97 105 77 65 80 109
85 97 88 68 83 68 71 69 67 74
62 82 98 101 79 105 79 69 62 73

Frequency Distribution

image

Frequency Distribution

image

Guidelines for Selecting Number of Classes

  • Use between 5 and 20 classes.

  • Data sets with a larger number of elements usually require a larger number of classes.

  • Smaller data sets usually require fewer classes

Guidelines for Selecting Width of Classes

  • Use classes of equal width

  • \(Approximate Class Width = \frac{Largest Value - Smallest Value}{Number of Classes}\)

Frequency Distribution

For this dataset, we can calculate, Approximate Class Width \(= (109 - 52)/6 = 9.5 \simeq 10\)

For Hudson Auto Repair, if we choose six classes:

image

Relative Frequency and Percentage Frequency Distributions

image

Histogram (simple version)

  • Another common graphical presentation of quantitative data is a histogram.

  • The variable of interest is placed on the horizontal axis.

  • A rectangle is drawn above each class interval with its height corresponding to the interval’s frequency, relative frequency, or percentage frequency.

  • Unlike a bar chart, a histogram has no natural separation between rectangles of adjacent classes.

image

Density Plot

The kernel density estimate to smooth the histogram, providing complementary information about the shape of the distribution:

image

Density Plot

A density plot is a robust way to get the shape of the distribution.

image image

Left: Bin Width = 10; Right: Bin Width = 5

Bar plot

A standard bar chart/ graph is a chart or graph that presents categorical data with rectangular bars with heights/lengths proportional to the values that they represent.

image image image

Bar plot

image

A bar plot represents an estimate of the central tendency for a numeric variable with the height of each rectangle and provides some indication of the uncertainty around that estimate using error bars.

Mosaic plot

image

A mosaic plot is a visualisation technique suitable for contingency tables that resembles a standardised/percentage stacked bar plot with the benefit that we still see the relative group sizes of the primary variable as well.

Boxplot

A box plot (box-and-whisker plot) shows the distribution of quantitative data in a way that facilitates comparisons between variables or across levels of a categorical variable.

image

  • Positive skewed (mean \(>\) median)

  • Upper whisker = Q3 + 1.5 * IQR, Lower whisker = Q1 - 1.5 * IQR

Violinplot/ Pirate Plot

A violin plot plays a similar role as a box and whisker plot. It shows the distribution of quantitative data across several levels of one (or more) categorical variables such that those distributions can be compared.

image

  • Components correspond to actual datapoints

  • Kernel density estimation

Data Process

Data Process

  • Raw Data

  • Pre-processing

    • Descriptive statistics

    • Plots for variables

    • Missing values or outliers

    • Next step for processing, e.g., checking distribution, correlation

  • Next step for analysis