2015年7月20日月曜日

データ分析の落し穴:因果と相関

「宿題の提出具合と成績の関連をモデル化」、つまり「宿題は成績にどう影響しているか」は、真っ当な分析に思えるが、果たしてどうなのだろうか?

本投稿はO'Reilly社の「R Cookbook」の「11.23 Performing Robust ANOVA (Kruskal–Wallis Test)」から。

分析方法は、中間試験の成績と提出された宿題の数を分散分析する。

中間試験の成績:
提出された宿題の数は、上記成績者と対応して並んでいる。

試験の成績は「正規分布していない」ので、一般的な ANOVA(分散分析)は使えない。そこで「Kruskal-Wallis Test(クラスカル・ワリス検定)」を使用。この辺の概要は、本書の以下の引用が分かりやすい。

Regular ANOVA assumes that your data has a Normal distribution. It can tolerate some deviation from normality, but extreme deviations will produce meaningless p-values. 
The Kruskal–Wallis test is a nonparametric version of ANOVA, which means that it does not assume normality. However, it does assume same-shaped distributions. You should use the Kruskal–Wallis test whenever your data distribution is nonnormal or simply unknown. P.308

次が、この分析結果。

実質的に「0」の p-value(0.00003669)から、成績と宿題数は大いに関係があるといえる。

本当にそうなのか?

本書の以下の引用を読むまでは、この分析結果から「宿題と成績は統計学的にも関係がある」と納得したが、これは「典型的な統計学上の誤り」であると気づく。

Obviously, there is a significant performance difference between students who complete their homework and those who do not. But what could I actually conclude? At first, I was pleased that the homework appeared so effective. Then it dawned on me that this was a classic error in statistical reasoning: I assumed that correlation implied causality. It does not, of course. Perhaps strongly motivated students do well on both homework and exams whereas lazy students do not. In that case, the causal factor is degree of motivation, not the brilliance of my homework selection.

つまり、「勉強のやる気がある生徒は、そもそも宿題も試験もちゃんとする」ということ。また「原因となるのはやる気であって、宿題の出来栄えではない」ということ。唯一結論できるのは、

In the end, I could only conclude something very simple: students who complete the homework will likely do well on the midterm exam, but I don’t really know why.
宿題をちゃんとする生徒は成績も良い傾向にあるが、その本当の理由は分からない。

「宿題と成績は関係する」というモデルで問題はないと考える人がいるかもしれないが、私も著者同様に、このモデルはそれほど有効とは思えない。「当たり前のことを示した」に過ぎない。

今回の分析は、「コーヒーの飲み過ぎは心臓病のリスクを高める」は、コーヒーと心臓病の因果関係というより「コーヒーに含まれる砂糖の方が因果関係が強い」、という例と同じ。

本書などで R を使って大量のデータ分析をしているが、今回のように「因果と相関」について「陥りやすい落とし穴」を忘れることがある。「因果と相関」については「ポスト・ビッグデータと統計学の時代(現代思想 2014年6月号)」にも書いたが、やはり簡単な問題ではない。

ただ、データ分析でしか、因果関係や相関関係を明確にできないのもまた事実。

Rクックブック
Rクックブック
posted with amazlet at 18.03.28
Paul Teetor
オライリージャパン
売り上げランキング: 14,860

0 件のコメント:

コメントを投稿