Correlation 1
Correlation 1
1 Introduction
We are often interested in the relationship between two variables.
Questions like this only make sense if the possible values of our variables have a natural
order. The techniques that we look at in this handout assume that variables are measured
on a scale that is at least ordinal. In discussing Pearson’s correlation coefficient, we shall
need to go further and assume that we have interval scale data - i.e. that equal intervals
correspond to equal changes in the characteristic that we are trying to measure.
– In the ‘Gas’ example, higher outside temperatures are associated with lower
gas consumption, but in the ‘Ice cream’ example, higher mean temperatures
go with higher levels of ice cream consumption.
1
1
r = − 0.971, ρ = − 0.958, τ = − 0.853 r = 0.776, ρ = 0.829, τ = 0.644
5
4
3
2.0
Direct current output
150
1.5
Crime rate
100
1.0
0.5
50
– The plot in the top left of Figure 1 shows a clear linear pattern, while the plot
in the bottom right suggests a non-linear relationship with the initial steep
slope leveling off as the wind speed increases.
– Figure 2 shows a plot of Police expenditure per head against Population size
2
for 47 US states2 . At first glance, there seems to be an increasing relationship,
with larger states spending more per head on policing. But if you cover up the
two points at the top right of the plot, the correlation seems to disappear. The
evidence for a correlation comes almost entirely from these two points, so we’ll
need to check our data source to make sure that the points really are correct.
160
140
Police expenditure per head
120
100
80
60
40
0 50 100 150
3
3 Correlation coefficients
A correlation coefficient gives a numerical summary of the degree of association between
two variables - e,g, to what degree do high values of one variable go with high values of
the other one?
Correlation coefficients vary from -1 to +1, with positive values indicating an increasing
relationship and negative values indicating a decreasing relationship.
We focus on two widely used measures of correlation - Pearson’s r and Kendall’s τ .
• Pearson’s coefficient
• Kendall’s coefficient
Spearman’s rank correlation coefficient, ρ behaves in much the same way as Kendall’s τ ,
but has a less direct interpretation.
4
a linear association, it can be quite misleading in the presence of curvature. Look at the
wind turbine data in the bottom right plot of Figure 1. Pearson’s r is 0.935, suggesting a
strong linear association, but a linear model would clearly not be sensible here.
Because Pearson’s r is based on the idea of linearity, it only makes sense for data that is
measured on at least an interval scale. For ordinal data, use Kendall’s τ or Spearman’s ρ.
C −D
τb = q
(n(n − 1)/2 − tx )(n(n − 1)/2 − ty )
5
. . . where tx is the number of tied x values and ty is the number of tied y values.
This version of Kendall’s τ is the one used by SPSS.
• Correlation is not the same as causality. For example, factories with more safety
officers may have fewer accidents, but this doesn’t prove that the variation in acci-
dent levels is attributable to the provision of safety officers. The correlation may be
a spurious one induced by another factor such as the age of the factory.
One possible approach here is to use partial correlation. We ’adjust’ our two vari-
ables to remove any variation that can be accounted for by our third variable (age
of factory) and then look at the correlation between the two adjusted variables.
45
40
40
Fuel economy
Fuel economy
35
35
30
30
25
25
• Correlation coefficients are subject to sampling variation and may give a misleading
picture of the correlation in the population we’re sampling. We can quantify the
uncertainty in an estimate of a correlation by quoting a confidence interval, or
6
range of plausible values. For the ’Ice cream’ data in Figure 1, the 95% confidence
interval for Pearson’s r is 0.576 to 0.888, so we can be fairly sure that the population
coefficient lies in this range.
For details of how to calculate confidence intervals for correlation coefficients, see
Howells(1994) and Hollander(1999).