Skip to content
QDA2 Lab

MODULE 09

Spread, Variance & Error

Averages are intuitive. Why do we need anything else? A visual lab about spread, squares and error.

Examples on this page use constructed or simulated teaching data, not empirical findings. About the data

  1. Research question
  2. Variables
  3. Variable roles
  4. Measurement levels
  5. Method choice
  6. Statistical logic (trained here)
  7. SPSS workflow
  8. Output interpretation (trained here)
  9. Defensible conclusion (trained here)

Understand

The trouble with averages

The mean and the median answer one question well: where is the middle? Every method in this course also needs a second answer: how much do cases differ from that middle, and from each other?

Four groups, one average

Synthetic data: four groups of 20 respondents rate their trust in parliament from 0 to 10. A report says “average trust: 5.0, median 5” for every group. Are the groups alike?

Group A: consensus
012345678910median▲ mean (balance point)
Group B: spread out
012345678910median▲ mean (balance point)
Group C: polarised
012345678910median▲ mean (balance point)
Group D: long right tail
012345678910median▲ mean (balance point)

Each dot is one respondent. ▲ marks the mean, the point where the dots would balance; the dashed line marks the median.

GroupMeanMedianSDMinMax
Group A: consensus5.05.0???
Group B: spread out5.05.0???
Group C: polarised5.05.0???
Group D: long right tail5.05.0???

One person can move the mean, but not the median

Synthetic monthly net incomes (thousand HUF) of nine people. Raise the ninth person’s income and watch where the balance point goes.

520k HUF
0k1,000k2,000k3,000k4,000k5,000kninth personmean 394kmedian 390k

Mean 394k, median 390k. 5 of 9 people earn less than the mean.

Mean

394k

Median

390k

Below the mean

5 of 9

The median only asks who is in the middle, so it stays at 390k. The mean is a balance point: every unit of distance counts, so one far-away value drags it along.

Why statistics gets more complicated

A centre alone hides spread (do people agree?), shape (one peak, two camps, a long tail?) and unusual cases. Every test you have met compares a difference with the spread around it: χ² compares observed with expected counts, t divides a mean difference by its standard error, F divides between-group by within-group variation. So we need a number for spread, and a picture of the whole distribution.

Understand

Spread as squares

Measure how far each observation is from the mean. The deviations always sum to zero, so we square them: each deviation becomes a real square, and spread becomes area.

Variance is an average square

Synthetic data: how many books six respondents read last year. Drag a dot up or down, or choose a respondent and use the slider.

Show
05101520mean 7.0ABCDEF

Dots = respondents; dashed line = mean; vertical lines = deviations from the mean. In the squared view each deviation becomes a square whose side is the deviation, so its area is the squared deviation.

Respondent to move

15

Respondent F: 15 books. Mean 7.0, sum of squares 106.0, variance 21.2, standard deviation 4.60.

Mean

7.0

Sum of deviations

0.0

Sum of squares

106.0

Variance = SS ÷ 5

21.2

SD = √variance

4.60

RespondentBooksDeviation from meanSquared deviation
A2-5.025.0
B4-3.09.0
C5-2.04.0
D70.00.0
E92.04.0
F158.064.0
Sum420.0106.0
s2=∑i(xi−xˉ)2n−1=sum of squaresn−1s^2 = \frac{\sum_i (x_i - \bar{x})^2}{n - 1} = \frac{\text{sum of squares}}{n-1}

Variance: the total area of the squares, shared out over n − 1. It is in squared units (books²).

s=s2s = \sqrt{s^2}

Standard deviation: the side of the average square, back in the original unit (books). Large deviations count disproportionately: a deviation of 8 adds 64, one of 2 adds only 4.

Why n − 1 and not n? The deviations are measured from the sample’s own mean, which sits exactly in the middle of these observations, so they come out slightly too small. Dividing by n − 1 corrects for that; it is what SPSS reports.

Understand

Deviations from a prediction: residuals

Now measure each person not from the overall mean but from a better guess for them: their group's mean, or a line on X. What is left is the residual, the part of Y the prediction does not account for.

From total spread to what is left over

Synthetic data: weekly hours of news use (X) and a political knowledge score (Y) for eight respondents. Choose what we use to predict each person’s score, and compare the squares that are left.

02040608010002468101214X: news hours per weekY: knowledge score

Dots = respondents; the thick line = the prediction (dashed when it is simply the mean of Y). Each vertical line is a respondent’s error, observed minus predicted, and each square has that error as its side.

Prediction: the mean of Y. Sum of squared errors 1739.9, 100 percent of the total 1739.9.

Area left over: 1739.9Total spread around the mean of Y: 1739.9

Slope used

0.00

Sum of squared errors

1739.9

Share of total spread left

100.0%

Share accounted for

0.0%

Predicting everyone with the mean (50.6) leaves the full total sum of squares, 1739.9. This is the starting point of ANOVA and of correlation: all the spread there is to account for.

∑(yi−yˉ)2⏟total  =  ∑(y^i−yˉ)2⏟accounted for  +  ∑(yi−y^i)2⏟residual\underbrace{\sum (y_i-\bar{y})^2}_{\text{total}} \;=\; \underbrace{\sum (\hat{y}_i-\bar{y})^2}_{\text{accounted for}} \;+\; \underbrace{\sum (y_i-\hat{y}_i)^2}_{\text{residual}}

This split holds when the predictions ŷ come from the least-squares line (or, in ANOVA, from the group means). For any other tilt of “your line” the two parts no longer add up to the total, which is one more reason the best line is the one we use.

You have seen this split before: ANOVA

In one-way ANOVA the prediction for each person is their group mean. SS within is the area of the residual squares, SS between is the part the group means account for, and η² = SS between ÷ SS total.

…and in correlation

With a straight line as the prediction, the share accounted for is r². A correlation of r=.5r = .5 means the best line removes only 25% of the squared spread. See the correlation module.

Try

Error terms: why their spread matters

Behind every sample stands a population in which people also differ from the line. That error is invisible; the residuals are our estimate of it. Its spread decides how much one sample can be trusted.

Where the error term comes from, and why it matters

A simulation: in an invented population, knowledge = 30 + 3 × news hours + error. The error is everything else that differs between people. Each sample gives a slightly different line.

10 points

How far people typically fall from the population line.

n = 30
-2002040608010012002468101214

Dots = the first sample; thick black line = its fitted line; shaded ribbon = ± one residual SD around it; thin grey lines = fitted lines of 24 other samples; dashed line = the population line (known here only because we invented the population).

Error SD 10, n 30. Residual SD 9.7, slope 2.31, standard error 0.50, t 4.62, p < .001. Slopes across 25 samples vary with SD 0.45.

Residual SD (typical error)

9.7

Slope in this sample

2.31

Standard error of the slope

0.50

SD of the 25 slopes (observed wobble)

0.45

t (df 28) = slope ÷ SE

4.62

p (two-tailed)

< .001

The residuals of one sample are our only window on the error term. Their SD (9.7) estimates how far people fall from the line, and from it we get the standard error: a prediction of how much the slope would wobble from sample to sample. Compare it with the wobble we can actually see (0.45). Bigger errors widen the ribbon and the wobble; larger samples calm the wobble but not the ribbon. The t value is the slope measured in standard errors, the same t that tests a Pearson correlation.

SE(b)=sresidual∑(xi−xˉ)2SE(b) = \frac{s_{\text{residual}}}{\sqrt{\sum (x_i-\bar{x})^2}}

Bigger residual spread → bigger standard error. More cases or a wider range of X → smaller standard error.

t=bSE(b),SE(xˉ)=snt = \frac{b}{SE(b)}, \qquad SE(\bar{x}) = \frac{s}{\sqrt{n}}

The same logic as the t-tests: an estimate divided by its standard error, which is built from the spread of the data.

Try

A first look at heteroscedasticity

The standard error above uses one residual SD for everyone. That is only fair if the errors are about the same size at every value of X.

Is the error the same size everywhere?

Simulated data, 150 respondents. All three versions have the same line and the same average error; only where the error is large changes. The lower chart plots each residual (observed minus predicted) against X.

Knowledge score (Y) against news hours (X)Residuals against X (0 = exactly on the line)04080120-4004002468101214±10.1±11.6±8.8

Shaded bands: ± the typical residual (root mean square) within each third of the X range, with the number printed in the lower chart.

Constant spread. Typical residual: low X 10.1, middle 11.6, high X 8.8.

Typical residual, low X

10.1

Typical residual, middle X

11.6

Typical residual, high X

8.8

One overall residual SD

10.4

The residuals form an even horizontal band: the typical error at high X (8.8) is about the same as at low X (10.1); the small difference is sampling noise. This is homoscedasticity (equal spread), the situation the usual standard error assumes.

The group version is already in your SPSS output

In the independent-samples t-test, Levene’s test asks whether two groups have the same variance, and the “Equal variances not assumed” (Welch) row is the answer when they do not. In ANOVA the homogeneity-of-variance test plays the same role. A funnel in a residual plot is the same issue with a continuous X. Handling it formally belongs to regression, later in your studies.

SPSS

Ask SPSS for spread, not just the centre

Descriptive output should always pair a centre with a spread, and a picture of the distribution.

Before you open SPSS

  1. 1Which variable?Ytrust in parliament 0–10
  2. 2Separately by group?Yes: Xgroup as factor
  3. 3Which statistics?Mean and median for the centre; SD (or variance), minimum, maximum for the spread; skewness for the shape.
  4. 4Which picture?Histogram or boxplot per group: the shape is the point.
Analyze›Descriptive Statistics›Explore
Descriptives: trust (condensed from Explore, synthetic data)
GroupNMeanMedianVarianceStd. DeviationMinimumMaximumSkewness
A205.005.000.840.92370.00
B205.005.008.002.830100.00
C205.005.0016.534.070100.00
D205.005.003.051.753101.84
  1. 1Identical means (and medians) in all four groups: the centre does not tell them apart.
  2. 2The SD does: from under 1 point (consensus) to about 4 points (polarised). Skewness flags group D's long right tail.
Explore also gives a 95% CI for the mean, the interquartile range, kurtosis, histograms and boxplots. In SPSS: Plots → Histogram; Factor List: the group variable.

Even this table cannot show that group C is split into two camps: the SD is large, but a wide spread and two camps can share an SD. Always look at the histogram.

Test yourself

Mastery check

Mastery check

0/0 correct on first attempt

Interpret a summary

Two seminar groups both have a mean of 5.0 and a median of 5 on a 0–10 trust scale. What can you conclude about how similar the two groups' answers are?

1 / 7