SL 4.10 — Spearman’s rank correlation coefficient(Spearmanの順位相関係数)
- データを rank(順位)に直せる。同じ値があるときは順位を平均する。
- \(r_s\)(Spearman’s rank correlation coefficient)を電卓で求められる。
- \(r_s\) の値を、問題の文脈に戻して言葉で説明できる。
- Pearson の \(r\) と Spearman の \(r_s\) の違いを説明できる。
- \(r\) は linear(直線)の関係だけ
- \(r_s\) は monotonic(ずっと増える/ずっと減る)関係なら何でも
- \(r_s\) のほうが outlier に強いことを、理由をつけて説明できる。
公式集の Topic 4 の欄は SL 4.8 で終わっています。 SL 4.9 と同じく、この項目の式も印刷されていません。
理由はシラバスに書いてあります。
In examinations Spearman’s rank correlation coefficient, \(r_s\), should be found using technology.
さらに、こうも書かれています。
Not required: Derivation/proof of Pearson’s product moment correlation coefficient and Spearman’s rank correlation coefficient.
証明は出ません。 この項目でやることは、順位を作ることと、出た \(r_s\) を言葉で説明することの2つです。
The idea
1. Spearman’s \(r_s\) とは ── 順位に付けかえた \(r\)
SL 4.4 で Pearson’s \(r\) を求めました。あれはデータの値そのものを使っていました。
Spearman’s rank correlation coefficient(順位相関係数)\(r_s\) は、値のかわりに順位を使って、同じ計算をしたものです。
\[ r_s = (\text{順位に付けかえたデータの、Pearson's } r) \tag{1}\]
やることは2段階だけです。
- それぞれの変数を、順位に直す
- その順位を使って、SL 4.4 と同じように Pearson’s \(r\) を計算する
新しい計算は何もありません。 \(r\) の出し方は SL 4.4 で身に付けたものが、そのまま使えます。
2. 順位のつけ方
この本では、大きいほうから \(1\) 位とします。一番大きい値が \(1\) 位です。
| 値 | 12 | 15 | 9 | 20 |
|---|---|---|---|---|
| 順位 | 3 | 2 | 4 | 1 |
日常の「\(1\) 位」と同じ向きです。テストなら一番点が高い人が \(1\) 位、コンテストなら一番よかった出場者が \(1\) 位。IB の問題も、審査員の順位づけや競技の成績など、この向きが自然な場面でよく出てきます。
IB は向きを決めていません。 両方の変数で同じ向きにそろえれば、\(r_s\) はまったく同じ値になります。
ただし片方だけ逆向きにすると、符号が反対になってしまいます。
どちらの向きでもよいので、必ず2つの変数でそろえてください。 問題文に rank 1 for the highest のような指定があれば、それに従います。
3. 同じ値があるときは、順位を平均します
シラバスに名指しで書かれている決めごとです。
If data items are equal, ranks should be averaged.
たとえば \(2\) 位と \(3\) 位の場所に同じ値が2つ並んだら、順位を平均して、
\[ \frac{2 + 3}{2} = 2.5 \]
両方とも \(2.5\) 位にします。そして次の値は \(4\) 位です。\(3\) 位は飛ばします。
| 値 | 20 | 15 | 15 | 12 | 9 |
|---|---|---|---|---|---|
| 順位 | 1 | 2.5 | 2.5 | 4 | 5 |
3つ並んだときも同じです。 \(4\)、\(5\)、\(6\) 位の場所に同じ値が3つなら、
\[ \frac{4 + 5 + 6}{3} = 5 \]
で、3つとも \(5\) 位。次は \(7\) 位です。
\(2.5\) 位や \(5.5\) 位という順位に違和感があるかもしれませんが、シラバスがそうしろと指定しています。
整数に丸めたり、\(2\) 位と \(3\) 位を勝手に決めたりしないでください。平均した値を、そのまま電卓に入れます。
4. \(r_s\) の読み方
\(r_s\) も、\(r\) と同じく \(-1\) から \(1\) までの値をとります。
| \(r_s\) | 意味 |
|---|---|
| \(r_s = 1\) | 順位が完全に一致。ずっと増える関係(perfectly monotonic increasing) |
| \(r_s\) が \(1\) に近い | 強い正の monotonic な関係 |
| \(r_s \approx 0\) | monotonic な関係がほとんどない |
| \(r_s\) が \(-1\) に近い | 強い負の monotonic な関係 |
| \(r_s = -1\) | 順位が完全に逆。ずっと減る関係 |
強さの言葉(strong / moderate / weak)は SL 4.4 の \(r\) と同じでよいのですが、「linear」とは言えません。 ここが \(r\) との一番の違いです。次の節で見ます。
5. \(r\) と \(r_s\) の違い
シラバスに、2つのはっきりした違いが書かれています。
Pearson’s product moment correlation coefficient is useful when testing for only linearity and Spearman’s correlation coefficient for any monotonic relationship.
Spearman’s correlation coefficient is less sensitive to outliers than Pearson’s product moment correlation coefficient.
違い(1) ── linear だけか、monotonic なら何でもか
monotonic(単調)とは、「ずっと増えつづける」か「ずっと減りつづける」という意味です。まっすぐである必要はありません。
図 1 の右側を見てください。曲がっていますが、\(x\) が増えれば \(y\) も必ず増えています。
- \(r = 0.880\) … 直線ではないので、\(1\) より小さくなります
- \(r_s = 1.000\) … 順位は完全に一致しているので、ぴったり \(1\) です
曲がっていても、順位さえ合っていれば \(r_s = 1\) になります。 これが \(r_s\) の強みです。
違い(2) ── outlier への強さ
図 2 は、\(1\) つの点を大きく動かしただけの同じデータです。
| \(r\) | \(r_s\) | |
|---|---|---|
| outlier なし | \(0.998\) | \(1.000\) |
| outlier あり | \(0.660\) | \(0.976\) |
\(r\) は \(0.998\) から \(0.660\) まで落ちました。 いっぽう \(r_s\) は \(1.000\) から \(0.976\) にしか動いていません。
\(r_s\) は「順位」しか見ていないからです。
図 2 で \(7\) 番目の点は \(12\) から \(40\) へ、大きく動きました。\(r\) はこの \(40\) という値をそのまま計算に使うので、大きく影響を受けます。
でも順位で見ると、この点は \(2\) 位から \(1\) 位に上がっただけです。\(1\) つずれただけなので、\(r_s\) はほとんど変わりません。
「どれだけ離れているか」ではなく「何番目か」しか見ない。 これが \(r_s\) の性質です。
| こう調べたい | どちらを使うか |
|---|---|
| 直線の関係(linear relationship)を調べたい | Pearson’s \(r\) |
| monotonic relationship(ずっと増える/減る関係)を調べたい | Spearman’s \(r_s\) |
| regression line で予測したい | Pearson’s \(r\)(SL 4.4) |
「outlier があるから Spearman」と自動的に決めないでください。 選ぶ基準は、monotonic relationship を調べたいのか、それとも linear regression による予測が必要なのかです。outlier に強いことは、\(r_s\) を選ぶ理由の \(1\) つにはなりますが、それだけで決まるわけではありません。
そもそも、その outlier が有効なデータなのか記録ミスなのかを先に確かめてください(SL 4.1)。記録ミスなら、係数を変えるより前に、データのほうを直します。
Which is more appropriate と聞かれたら、何を調べたいのかを言い、理由を1文つけてください。
\(r_s\) は順位しか見ていないので、「\(x\) が \(10\) のとき \(y\) はいくつか」には答えられません。
予測が必要なら、SL 4.4 の regression line(回帰直線)を使います。\(r_s\) に回帰直線はありません。
Why it works
ここでは、なぜ順位に付けかえると、曲がった関係もとらえられるのかだけを説明します。
Pearson’s \(r\) は、点が1本の直線にどれだけ近いかを測っています(SL 4.4)。ですから 図 1 の右のように曲がっていると、どれだけきれいな関係でも \(r\) は \(1\) になりません。
ここで、データを順位に付けかえると何が起きるでしょうか。
順位は \(1, 2, 3, 4, \ldots\) と、必ず等間隔に並びます。 もとの \(y\) が \(2, 3, 5, 9, 16, 28, 50, 90\) とどれだけ急に増えていても、順位にすれば(大きいほうから)\(8, 7, 6, 5, 4, 3, 2, 1\) という等間隔の数に置きかわります。
\(x\) の順位も同じく \(8, 7, 6, \ldots, 1\) ですから、順位どうしをグラフにすると、完全な直線になります。だから \(r_s = 1\) です。
曲がりぐあいの情報を捨てて、順番だけを残す。 これが順位に付けかえるということです。
同じ理由で、outlier の影響も Pearson’s \(r\) より小さくなることが多いです。ただし、完全になくなるわけではありません。 順位が入れかわるほど大きく外れていれば、\(r_s\) も動きます。
教科書によっては、次の式が載っていることがあります。
\[ r_s = 1 - \frac{6 \sum d^{2}}{n(n^{2} - 1)} \]
\(d\) は、それぞれの組の順位の差です。
ただし、この式は AI SL の公式集に載っていません。 シラバスが「電卓で求めること」と指定しているので、使う必要もありません。
さらに、同じ値があって順位を平均したときには、この式は正確ではなくなります。 正しい \(r_s\) は、あくまで 式 1 の「順位から計算した Pearson’s \(r\)」です。
電卓で出してください。 そのほうが速く、同順位があっても正しい値が出ます。
Worked examples
問題文は英語です。意味が理解できなかったら、問題文の下の「日本語訳」を開いてください。解説は日本語です。
例題 1 The table shows the number of hours eight students spent revising and their test scores.
| Hours | 3 | 7 | 5 | 10 | 7 | 2 | 8 | 6 |
|---|---|---|---|---|---|---|---|---|
| Score | 45 | 72 | 60 | 88 | 68 | 38 | 80 | 64 |
(a) Write down the rank of each value, ranking from highest to lowest.
(b) Find Spearman’s rank correlation coefficient, \(r_s\).
(c) Interpret your answer in context.
日本語訳
表は、\(8\) 人の生徒が復習に使った時間と、テストの得点を示しています。見出しの Hours は「時間」、Score は「得点」です。
(a) それぞれの値の順位を、大きいほうから順に書きなさい。
(b) Spearman の順位相関係数 \(r_s\) を求めなさい。
(c) 答えの意味を、問題の文脈で説明しなさい。
(a) Hours に \(7\) が2つあります。 ここが山場です。
大きい順に並べると \(10, 8, 7, 7, 6, 5, 3, 2\) なので、\(7\) は \(3\) 番目と \(4\) 番目の場所に来ます。ですから順位を平均して、
\[ \frac{3 + 4}{2} = 3.5 \]
両方とも \(3.5\) 位です。次の \(6\) は \(5\) 位(\(4\) 位は飛ばします)。
| Hours | 3 | 7 | 5 | 10 | 7 | 2 | 8 | 6 |
|---|---|---|---|---|---|---|---|---|
| Hours rank | 7 | 3.5 | 6 | 1 | 3.5 | 8 | 2 | 5 |
| Score | 45 | 72 | 60 | 88 | 68 | 38 | 80 | 64 |
| Score rank | 7 | 3 | 6 | 1 | 4 | 8 | 2 | 5 |
Score には同じ値がないので、こちらはふつうに \(1\) から \(8\) です。
検算。 どちらの行も、足すと \(\dfrac{8 \times 9}{2} = 36\) になります ✓
(b) 順位の2列を使って、SL 4.4 と同じ Linear Regression を実行します。(GDCの使い方)
menu → Statistics → Stat Calculations → Linear Regression (a+bx)
\(x\) には Hours の順位、\(y\) には Score の順位を指定します。出てきた \(r\) が \(r_s\) です。
\[ r_s = 0.994 \quad (3 \text{ s.f.}) \]
(c) Interpret なので、言葉で説明します。
試験ではこう書く
There is a very strong positive monotonic relationship between the number of hours spent revising and the test score: students who revised for longer generally scored higher.
(意味:復習時間と得点のあいだには、非常に強い正の monotonic な関係がある。長く復習した生徒ほど、おおむね高い得点だった。)
「\(r_s\) が大きい」だけでは点になりません。 「復習時間」と「得点」という問題の言葉に戻して書いてください。
(a)
| Hours rank | 7 | 3.5 | 6 | 1 | 3.5 | 8 | 2 | 5 |
|---|---|---|---|---|---|---|---|---|
| Score rank | 7 | 3 | 6 | 1 | 4 | 8 | 2 | 5 |
(b) \(r_s = 0.994\) (3 s.f.)
(c) There is a very strong positive monotonic relationship between revision time and test score: students who revised for longer generally scored higher.
例題 2 Two judges each award a score to eight competitors in a competition. Their scores are shown in the table.
| Competitor | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| Judge 1 | 8.5 | 7.0 | 9.2 | 6.1 | 8.0 | 9.5 | 7.5 | 6.8 |
| Judge 2 | 8.0 | 7.2 | 9.0 | 6.5 | 7.8 | 9.4 | 7.0 | 6.2 |
(a) Find Spearman’s rank correlation coefficient, \(r_s\).
(b) Comment on the level of agreement between the two judges.
日本語訳
\(2\) 人の審査員が、コンテストの \(8\) 人の出場者にそれぞれ点を付けました。見出しの Competitor は「出場者」、Judge は「審査員」です。
(a) Spearman の順位相関係数 \(r_s\) を求めなさい。
(b) \(2\) 人の審査員の意見がどれくらい一致しているか、コメントしなさい。
(agreement は「一致」です。)
(a) どちらの行にも同じ値はありません。ふつうに \(1\) 位から \(8\) 位まで付けます。
| Competitor | A | B | C | D | E | F | G | H |
|---|---|---|---|---|---|---|---|---|
| Judge 1 rank | 3 | 6 | 2 | 8 | 4 | 1 | 5 | 7 |
| Judge 2 rank | 3 | 5 | 2 | 7 | 4 | 1 | 6 | 8 |
違うのは B、D、G、H のところだけです。あとは完全に同じ順位です。
順位の2列で Linear Regression を実行して、
\[ r_s = 0.952 \quad (3 \text{ s.f.}) \]
(b) Comment on なので、言葉で答える設問です。
試験ではこう書く
Since \(r_s = 0.952\) is very close to \(1\), the two judges ranked the competitors in almost the same order. There is a very high level of agreement between them.
(意味:\(r_s = 0.952\) は \(1\) にとても近いので、\(2\) 人の審査員はほぼ同じ順序で出場者を並べた。\(2\) 人の意見は非常によく一致している。)
審査員には点の付け方のくせがあります。\(1\) 人は \(6\) 〜 \(10\) 点の幅で付け、もう \(1\) 人は \(2\) 〜 \(9\) 点の幅で付けるかもしれません。
それでも「誰を上位にしたか」を比べたいのなら、点そのものより順位のほうが公平です。だから \(r_s\) を使います。
(a) \(r_s = 0.952\) (3 s.f.)
(b) Since \(r_s = 0.952\) is very close to \(1\), the two judges ranked the competitors in almost the same order, so there is a very high level of agreement.
例題 3 A scientist records the number of bacteria in a sample at eight different times.
| Time (hours) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Bacteria (thousands) | 2 | 3 | 5 | 9 | 16 | 28 | 50 | 90 |
(a) Find Pearson’s product moment correlation coefficient, \(r\).
(b) Find Spearman’s rank correlation coefficient, \(r_s\).
(c) State which of the two coefficients is more appropriate for this data, giving a reason.
日本語訳
ある科学者が、\(8\) 回にわたって試料の中の細菌の数を記録しました。見出しの Time (hours) は「時間(時)」、Bacteria (thousands) は「細菌の数(千個)」です。
(a) Pearson の積率相関係数 \(r\) を求めなさい。
(b) Spearman の順位相関係数 \(r_s\) を求めなさい。
(c) このデータには \(2\) つの係数のどちらがより適切かを、理由をつけて述べなさい。
(a) もとの値のまま Linear Regression を実行します(SL 4.4 のとおり)。
\[ r = 0.880 \quad (3 \text{ s.f.}) \]
(b) 今度は順位に直してから実行します。\(x\) も \(y\) も増えていく順に並んでいるので、大きいほうから付けると、順位は \(8\) 位から \(1\) 位へ下がっていきます。
| Time rank | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bacteria rank | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
2つの行が完全に同じです。ですから、
\[ r_s = 1 \]
(c) State ... giving a reason なので、選んで、理由を書きます。
散布図をかくと、図 1 の右のように急に立ち上がる曲線になります。直線ではありません。
試験ではこう書く
Spearman’s \(r_s\) is more appropriate. The number of bacteria increases at an increasing rate, so the relationship is not linear, and Pearson’s \(r\) only measures how close the data is to a straight line. The relationship is monotonic, which is what \(r_s\) measures, and \(r_s = 1\) shows that it is perfectly increasing.
(意味:Spearman の \(r_s\) のほうが適切である。細菌の数は増える速さがどんどん上がっているので関係は直線ではなく、Pearson の \(r\) は直線への近さしか測れない。この関係は monotonic であり、それを測るのが \(r_s\) である。\(r_s = 1\) なので、完全に増えつづける関係だと分かる。)
monotonic(単調)は、単調に増加するか単調に減少するか、という意味です。ここは \(r_s = 1\) なので、単調に増加しています。
\(r = 0.880\) を見て「そこそこ強い」と答えて終わらないでください。 本当は完全にきれいな関係なのに、\(r\) ではそれが見えていません。
(a) \(r = 0.880\) (3 s.f.)
(b) \(r_s = 1\)
(c) Spearman’s \(r_s\) is more appropriate, because the relationship is not linear but is monotonic increasing. Pearson’s \(r\) only measures linearity, so it underestimates the strength of this relationship.
例題 4 The table shows eight pairs of values.
| \(x\) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| \(y\) | 3 | 5 | 6 | 8 | 9 | 11 | 40 | 14 |
(a) Identify the outlier.
(b) Find \(r\) and \(r_s\) for this data.
(c) The value \(y = 40\) is replaced by \(y = 12\). The new values are \(r = 0.998\) and \(r_s = 1\). Comment on the effect of the outlier on each coefficient.
日本語訳
表は \(8\) 組の値を示しています。
(a) outlier を特定しなさい。
(b) このデータの \(r\) と \(r_s\) を求めなさい。
(c) \(y = 40\) を \(y = 12\) に置きかえると、新しい値は \(r = 0.998\)、\(r_s = 1\) になります。それぞれの係数に対する outlier の影響についてコメントしなさい。
(a) \(y\) の値は \(3, 5, 6, 8, 9, 11, \ldots, 14\) とゆるやかに増えているのに、\(x = 7\) のところだけ \(40\) です。
\[ (x, y) = (7,\ 40) \]
(b) そのままの値で \(r\)、順位に直して \(r_s\)。
\[ r = 0.660, \qquad r_s = 0.976 \quad (3 \text{ s.f.}) \]
\(y\) の順位を見ておきましょう。\(40\) は一番大きいので \(1\) 位、\(14\) が \(2\) 位です。入れかわったのはこの2つだけです。
| \(x\) rank | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| \(y\) rank | 8 | 7 | 6 | 5 | 4 | 3 | 1 | 2 |
(c) Comment on なので、言葉で答えます。 数字を並べるだけでは足りません。
| outlier あり | outlier なし | |
|---|---|---|
| \(r\) | \(0.660\) | \(0.998\) |
| \(r_s\) | \(0.976\) | \(1\) |
試験ではこう書く
The outlier has a large effect on Pearson’s \(r\), which falls from \(0.998\) to \(0.660\), because \(r\) uses the actual values and the outlier lies far from the straight line. It has only a small effect on Spearman’s \(r_s\), which falls from \(1\) to \(0.976\), because \(r_s\) uses only the ranks and the outlier moves that point by just one rank position.
(意味:outlier は Pearson の \(r\) に大きく影響し、\(0.998\) から \(0.660\) まで下がる。\(r\) は実際の値を使うので、直線から大きく離れた点の影響を受けるからである。いっぽう Spearman の \(r_s\) への影響は小さく、\(1\) から \(0.976\) に下がっただけである。\(r_s\) は順位しか使わず、この点は順位で \(1\) つ動いただけだからである。)
「\(r_s\) のほうが outlier に強い」で終わらせず、「順位しか使っていないから」という理由まで書いてください。理由が点になります。
(a) The outlier is \((7,\ 40)\).
(b) \(r = 0.660\), \(r_s = 0.976\) (3 s.f.)
(c) The outlier has a large effect on \(r\) (\(0.998 \to 0.660\)) because \(r\) uses the actual data values. It has only a small effect on \(r_s\) (\(1 \to 0.976\)) because \(r_s\) uses only the ranks, and the outlier changes the rank of that point by only one place.
Common errors
この項目で一番多い間違いです。
\(2\) 位と \(3\) 位の場所に同じ値が2つ並んだら、両方とも \(2.5\) 位。次は \(4\) 位です。
\(2\) 位と \(3\) 位を勝手に決めてはいけません。 シラバスに ranks should be averaged と書かれています。
\(2.5\) 位が2つ来たら、次は \(4\) 位です。\(3\) 位ではありません。
\(2.5\) が2つで、\(2\) 位と \(3\) 位の両方を使いきっているからです。順位は全部で \(n\) 個ぶん使う、と考えると間違えません。
片方を「小さいほうから」、もう片方を「大きいほうから」付けると、符号が反対になります。
\(r_s = 0.9\) になるはずが \(-0.9\) になります。2つの変数で必ずそろえてください。
それでは Pearson’s \(r\) が出ます。\(r_s\) ではありません。
必ず、順位の列を作ってから実行してください。\(r\) と \(r_s\) は近い値になることも多いので、気づきにくい間違いです。
\(r_s\) が測っているのは monotonic(ずっと増える/減る)な関係です。
\(r_s = 1\) でも、直線とはかぎりません(図 1 の右)。
linear ではなく monotonic という語を使ってください。
\(r_s\) は順位しか見ていないので、\(y\) の値を予測することはできません。
予測には SL 4.4 の regression line が必要です。
Interpret や Comment on が付いていたら、問題の言葉に戻して1文書きます。
「\(r_s = 0.952\)」だけでなく、「\(2\) 人の審査員はほぼ同じ順序で並べた」まで書いてください。
Using your GDC (TI-Nspire CX II)
\(r_s\) を直接出すメニューはありません。
自分で順位の列を作って、その順位で Linear Regression を実行します。 出てきた \(r\) が、そのまま \(r_s\) です。
この手順を覚えることが、この項目の中身です。
手順
1. Lists & Spreadsheet に、もとのデータを2列入れます。
ctrl + doc → 4: Add Lists & Spreadsheet
列に名前を付けます(x、y など)。
2. 順位の列を、\(2\) 列作ります。
順位は自分で見て入れます。 列名は rx、ry などにしておきます。
数が多いときは、いったん並べかえると数えやすくなります。
menu → Actions → Sort
\(x\) の列だけを並べかえると、\(y\) の列との組み合わせがずれてしまいます。
\(8\) 個や \(10\) 個なら、紙に書いて数えるほうが速くて確実です。 電卓に入れるのは、順位が決まってからで構いません。
3. 順位の2列で、Linear Regression を実行します。
menu → Statistics → Stat Calculations → Linear Regression (a+bx)
X List…rx(順位のほう)Y List…ry(順位のほう)
4. 出てきた \(r\) を読みます。
\[ r_s = (\text{順位に対する } r) \]
画面には \(r\) としか出ません。 順位を入れたのだから \(r_s\) だ、と自分で分かっている必要があります。
\(r\) と \(r_s\) の両方を聞かれたら
同じ画面を2回使うだけです。
| 求めるもの | X List / Y List に指定する列 |
|---|---|
| \(r\)(Pearson) | もとの値の列(x、y) |
| \(r_s\)(Spearman) | 順位の列(rx、ry) |
列を取り違えると、まったく別のものが出ます。 指定するときに、列名を必ず確かめてください。
順位の検算
順位の合計で確かめられます。\(n\) 個の順位を全部足すと、必ず
\[ 1 + 2 + \cdots + n = \frac{n(n+1)}{2} \]
になります。\(n = 8\) なら \(36\) です。同順位を平均していても、合計は変わりません。
\[ \texttt{sum(rx)} \qquad \texttt{sum(ry)} \]
を計算して、2つとも \(36\) になれば、順位の付け方は正しいです。\(36\) にならなければ、飛ばしたか重ねたかしています。
不安な人は、覚えておいて使ってください。
Exercises
各問題に、折りたたみが3つ付いています。日本語訳、解答例(答案用紙に書くべきこと。英語です)、解説(なぜそうなるか。日本語です)。
まず自分で解いて、次に解答例と見くらべてください。解説は、合わなかったときだけ開けば十分です。
1 Rank the following values from highest to lowest, averaging the ranks of any equal values.
\[ 12, \quad 15, \quad 12, \quad 18, \quad 20, \quad 15, \quad 15, \quad 9 \]
日本語訳
次の値に、大きいほうから順位を付けなさい。同じ値があるときは、順位を平均しなさい。
| Value | 12 | 15 | 12 | 18 | 20 | 15 | 15 | 9 |
|---|---|---|---|---|---|---|---|---|
| Rank | 6.5 | 4 | 6.5 | 2 | 1 | 4 | 4 | 8 |
まず大きい順に並べます。
\[20, \quad 18, \quad 15, \quad 15, \quad 15, \quad 12, \quad 12, \quad 9\]
- \(20\) … \(1\) 位
- \(18\) … \(2\) 位
- \(15\) が3つ … \(3\)、\(4\)、\(5\) 位の場所なので \(\dfrac{3+4+5}{3} = 4\) 位
- \(12\) が2つ … \(6\) 位と \(7\) 位の場所なので \(\dfrac{6+7}{2} = 6.5\) 位(\(5\) 位までは使いきっています)
- \(9\) … \(8\) 位
検算。 全部足すと
\[6.5 + 4 + 6.5 + 2 + 1 + 4 + 4 + 8 = 36\]
\(\dfrac{8 \times 9}{2} = 36\) ✓ 合っています。
2 Eight students were ranked in a mathematics test and in a physics test. The ranks are shown in the table.
| Maths rank | 3 | 6 | 1 | 8 | 5 | 2 | 7 | 4 |
|---|---|---|---|---|---|---|---|---|
| Physics rank | 5 | 6 | 1 | 8 | 4 | 2 | 7 | 3 |
Find Spearman’s rank correlation coefficient, \(r_s\).
日本語訳
\(8\) 人の生徒に、数学のテストと物理のテストで順位が付けられました。順位は表のとおりです。
Spearman の順位相関係数 \(r_s\) を求めなさい。
\(r_s = 0.929\) (3 s.f.)
この問題では、すでに順位が与えられています。 順位を作る手間がないので、そのまま Linear Regression に入れるだけです。
menu → Statistics → Stat Calculations → Linear Regression (a+bx)
\(X\) に Maths rank、\(Y\) に Physics rank を指定して、\(r\) を読みます。
\[r_s = 0.9285\ldots = 0.929\]
ずれているのは \(3\) 位・\(4\) 位・\(5\) 位のあたりだけなので、\(1\) に近い値になるはずです。\(0.929\) は妥当です。
検算。 どちらの行も足すと \(36\) です ✓
3 The table shows the marks of eight students in a mathematics test and a physics test.
| Maths | 78 | 65 | 92 | 55 | 70 | 88 | 60 | 74 |
|---|---|---|---|---|---|---|---|---|
| Physics | 72 | 68 | 90 | 50 | 75 | 85 | 58 | 80 |
(a) Find \(r_s\).
(b) Interpret your answer in context.
日本語訳
表は、\(8\) 人の生徒の数学と物理のテストの得点を示しています。
(a) \(r_s\) を求めなさい。
(b) 答えの意味を、問題の文脈で説明しなさい。
(a) Ranks:
| Maths rank | 3 | 6 | 1 | 8 | 5 | 2 | 7 | 4 |
|---|---|---|---|---|---|---|---|---|
| Physics rank | 5 | 6 | 1 | 8 | 4 | 2 | 7 | 3 |
\[r_s = 0.929 \text{ (3 s.f.)}\]
(b) There is a strong positive monotonic relationship between the marks in the two tests: students who scored higher in mathematics generally scored higher in physics.
(a) 同じ値はありませんので、ふつうに \(1\) 位から \(8\) 位まで付けます。
Maths を大きい順に並べると \(92, 88, 78, 74, 70, 65, 60, 55\)。ですから \(78\) は \(3\) 位、\(65\) は \(6\) 位、というように付けていきます。
これは問2と同じ順位表になります。答えも同じ \(0.929\) です。
(b) Interpret なので言葉で。「数学の得点」「物理の得点」という問題の言葉を使ってください。
linear と書かないように。 \(r_s\) が測っているのは monotonic な関係です。
4 The table shows the value of a rare item at the end of each of seven years.
| Year | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Value (hundreds of dollars) | 5 | 7 | 11 | 20 | 38 | 75 | 150 |
(a) Find \(r\) and \(r_s\).
(b) State which coefficient better describes the relationship, giving a reason.
日本語訳
表は、ある希少品の \(7\) 年間の年末ごとの価値を示しています。見出しの Value (hundreds of dollars) は「価値(百ドル単位)」です。
(a) \(r\) と \(r_s\) を求めなさい。
(b) どちらの係数がこの関係をよりよく表しているかを、理由をつけて述べなさい。
(a) \(r = 0.872\) (3 s.f.), \(r_s = 1\)
(b) \(r_s\) describes the relationship better. The value increases every year, so the relationship is perfectly monotonic and \(r_s = 1\). However the increase is not linear — the value rises more and more steeply — so Pearson’s \(r\) is less than \(1\).
(a) \(r\) はもとの値、\(r_s\) は順位で実行します。
年も価値も増えていく順なので、大きいほうから付けると順位はどちらも \(7, 6, 5, 4, 3, 2, 1\)。完全に一致しているので \(r_s = 1\) です。
(b) 散布図をかくと、図 1 の右のように急に立ち上がる曲線になります。
- 価値は毎年必ず上がっている → monotonic → \(r_s = 1\)
- 直線ではない → \(r < 1\)
「\(r = 0.872\) だから強い相関」で終わらせないでください。 本当は完全にきれいな関係です。\(r\) ではそれが見えません。
5 The table shows eight pairs of values.
| \(x\) | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 |
|---|---|---|---|---|---|---|---|---|
| \(y\) | 20 | 26 | 31 | 35 | 40 | 95 | 50 | 55 |
(a) Find \(r\) and \(r_s\).
(b) Without the outlier the values would be \(r = 0.999\) and \(r_s = 1\). Comment on which coefficient is affected more, and explain why.
日本語訳
表は \(8\) 組の値を示しています。
(a) \(r\) と \(r_s\) を求めなさい。
(b) outlier がなければ \(r = 0.999\)、\(r_s = 1\) になります。どちらの係数がより大きく影響を受けるかをコメントし、その理由を説明しなさい。
(a) \(r = 0.692\) (3 s.f.), \(r_s = 0.929\) (3 s.f.)
(b) Pearson’s \(r\) is affected much more, falling from \(0.999\) to \(0.692\), because it uses the actual data values and the point \((12,\ 95)\) lies far from the straight line. Spearman’s \(r_s\) falls only from \(1\) to \(0.929\), because it uses only the ranks and the outlier changes that point’s rank by two places.
(a) outlier は \((12,\ 95)\) です。\(y\) の値がまわりから大きく外れています。
\(y\) の順位を見ます。\(95\) は一番大きいので \(1\) 位。\(55\) と \(50\) が \(1\) つずつ下がって、\(2\) 位と \(3\) 位になります。
| \(x\) rank | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| \(y\) rank | 8 | 7 | 6 | 5 | 4 | 1 | 3 | 2 |
(b) 数字を並べるだけでなく、理由を書いてください。
- \(r\) は値そのものを使う → \(95\) という大きな値に強く引っぱられる
- \(r_s\) は順位だけを使う → \(3\) 位が \(1\) 位になった、というだけ
シラバスの言葉は less sensitive to outliers です。 この一言を、自分の言葉で説明できるようにしておいてください。
6 The table shows the number of hours six people spent watching television and their score on a memory test.
| Hours | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Score | 100 | 82 | 71 | 60 | 45 | 30 |
(a) Find \(r_s\).
(b) Interpret your answer in context.
日本語訳
表は、\(6\) 人がテレビを見た時間と、記憶力テストの得点を示しています。
(a) \(r_s\) を求めなさい。
(b) 答えの意味を、問題の文脈で説明しなさい。
(a) \(r_s = -1\)
(b) There is a perfect negative monotonic relationship: as the number of hours watching television increases, the memory test score always decreases.
(a) Hours は \(6\) が一番大きいので、大きいほうから付けると \(6, 5, 4, 3, 2, 1\) 位。
Score は \(100\) が一番大きいので \(1\) 位。順に \(2, 3, 4, 5, 6\) 位となり、
| Hours rank | 6 | 5 | 4 | 3 | 2 | 1 |
|---|---|---|---|---|---|---|
| Score rank | 1 | 2 | 3 | 4 | 5 | 6 |
完全に逆なので \(r_s = -1\) です。
(b) perfect と negative の2語を入れてください。\(r_s = -1\) はただの「強い」ではなく、完全に逆順という意味です。
なお、これは「テレビを見ると記憶力が下がる」という意味ではありません。 SL 4.4 でやった correlation does not imply causation は、\(r_s\) でもまったく同じです。
7 State one advantage of using Spearman’s rank correlation coefficient rather than Pearson’s product moment correlation coefficient, and give an example of a situation in which it would be preferred.
日本語訳
Pearson の積率相関係数ではなく Spearman の順位相関係数を使うことの利点を \(1\) つ述べ、それが好まれる場面の例を挙げなさい。
(advantage は「利点」、preferred は「好まれる」です。)
Spearman’s \(r_s\) is less affected by outliers than Pearson’s \(r\), because it uses only the ranks of the data rather than the actual values.
For example, if a set of data on house prices contains one extremely expensive house, \(r\) would be pulled towards that point, while \(r_s\) would still describe the general trend.
利点は2つあります。 どちらか \(1\) つを書けば十分です。
- outlier に強い(順位しか使わないから)
- 曲がっていても、monotonic なら測れる(直線でなくてよい)
giving an example があるので、例が必ず要ります。 理由だけでは点が足りません。
例は身近なもので構いません。「1軒だけ極端に高い家がある住宅価格のデータ」「1人だけ極端な点を付ける審査員」など、outlier がありそうな場面を挙げてください。
8 A student calculates \(r_s = 0.95\) for a set of data and then uses a regression line to predict a value of \(y\).
Explain why the value of \(r_s\) does not justify making this prediction.
日本語訳
ある生徒が、あるデータについて \(r_s = 0.95\) を求め、そのあと回帰直線を使って \(y\) の値を予測しました。
\(r_s\) の値が、この予測の根拠にならない理由を説明しなさい。
(justify は「正当化する・根拠づける」です。)
\(r_s\) uses only the ranks of the data, so a value close to \(1\) shows that the relationship is monotonic but does not show that it is linear. A regression line assumes a linear relationship, so \(r_s\) cannot justify using one. Pearson’s \(r\) would be needed to judge whether a linear model is suitable.
回帰直線は「直線の関係」を前提にしています(SL 4.4)。
\(r_s = 0.95\) が言っているのは「順位がよく合っている」ということだけで、直線かどうかは何も言っていません。 図 1 の右のように、\(r_s = 1\) でも大きく曲がっていることがあります。
書くべきことは3つです。
- \(r_s\) は順位だけを使う
- だから monotonic は言えても linear は言えない
- 回帰直線を使いたいなら、\(r\) を見るべき
「\(r_s\) では予測できない」だけでは弱いです。なぜかまで書いてください。
9 A student writes: “For this data \(r_s = 1\), so the points lie on a straight line.”
Explain why this statement is not correct, and describe what \(r_s = 1\) does tell us.
日本語訳
ある生徒が「このデータでは \(r_s = 1\) なので、点は一直線上に並んでいる」と書きました。
この主張が正しくない理由を説明し、\(r_s = 1\) が実際に何を意味しているかを述べなさい。
(本書オリジナルの問題です。)
The statement is not correct. \(r_s\) is calculated from the ranks of the data, not from the values, so \(r_s = 1\) only means that the ranks of \(x\) and \(y\) agree exactly.
This tells us that the relationship is perfectly monotonic increasing: whenever \(x\) increases, \(y\) also increases. The points may still lie on a curve. Only \(r = 1\) would show that the points lie exactly on a straight line.
この本で何度か出てきた考え方です。
\(r_s = 1\) が言っているのは、「順位がぴったり同じ」ということだけ。図 1 の右の細菌のデータがまさにこれで、\(r_s = 1\) ですが、点は曲線の上にあります。
まっすぐだと言えるのは \(r = 1\) のときです。
答案では、次の対比をはっきり書いてください。
| 何が言えるか | |
|---|---|
| \(r_s = 1\) | 完全に monotonic increasing |
| \(r = 1\) | 点が完全に 一直線上 |
この2つを混ぜないことが、この項目の一番のねらいです。
10 A teacher records the number of practice papers eight students completed and their final examination mark.
| Papers | 4 | 9 | 6 | 12 | 9 | 3 | 10 | 7 |
|---|---|---|---|---|---|---|---|---|
| Mark | 52 | 74 | 61 | 90 | 70 | 45 | 82 | 66 |
(a) Write down the ranks of the two variables, ranking from highest to lowest.
(b) Find \(r_s\).
(c) Interpret your answer in context.
(d) The teacher says: “This shows that completing more practice papers causes a higher mark.” Comment on this statement.
日本語訳
ある先生が、\(8\) 人の生徒が解いた練習問題のセット数と、最終試験の得点を記録しました。見出しの Papers は「解いたセット数」、Mark は「得点」です。
(a) \(2\) つの変数の順位を、大きいほうから書きなさい。
(b) \(r_s\) を求めなさい。
(c) 答えの意味を、問題の文脈で説明しなさい。
(d) 先生は「これは、練習問題を多く解くことが高い得点の原因になっていることを示している」と言いました。この主張についてコメントしなさい。
(a)
| Papers rank | 7 | 3.5 | 6 | 1 | 3.5 | 8 | 2 | 5 |
|---|---|---|---|---|---|---|---|---|
| Mark rank | 7 | 3 | 6 | 1 | 4 | 8 | 2 | 5 |
(b) \(r_s = 0.994\) (3 s.f.)
(c) There is a very strong positive monotonic relationship: students who completed more practice papers generally achieved a higher mark.
(d) The statement is not justified. A strong correlation does not show causation. Other factors, such as how much a student studies overall or how motivated they are, could affect both the number of practice papers completed and the final mark.
(a) Papers に \(9\) が2つあります。 大きい順に並べると \(12, 10, 9, 9, 7, 6, 4, 3\) なので、\(9\) は \(3\) 位と \(4\) 位の場所です。
\[\frac{3 + 4}{2} = 3.5\]
両方とも \(3.5\) 位、次の \(7\) は \(5\) 位です。
検算。 \(7 + 3.5 + 6 + 1 + 3.5 + 8 + 2 + 5 = 36\) ✓(\(\dfrac{8 \times 9}{2} = 36\))
Mark には同じ値がないので、ふつうに \(1\) 位から \(8\) 位です。
(b) 順位の2列で Linear Regression を実行して \(r_s = 0.994\)。
(c) Interpret なので言葉で。「練習問題のセット数」「得点」という問題の言葉を使ってください。
(d) SL 4.4 の correlation does not imply causation と同じ話です。\(r_s\) でもまったく変わりません。
「別の要因を1つ挙げる」のが、この設問で点になるところです。「そもそもよく勉強する生徒だった」「やる気が高かった」など、両方に効きそうな要因を挙げてください。
ただし「関係がない」と言い切ってもいけません。 関係はあります。「原因だと言い切れない」が正しい答え方です。