2015年10月1日木曜日

OLS回帰分析の前提:Homoscedasticity

統計学には(ここでは「頻度主義者の統計学」を想定)様々な分析手法がある。

「頻度主義者の統計学 vs. ベイジアン」について書いたばかりなので、どうしても「この二つは区別すべきでは?」と不安になる。ちょっと面倒だが、そのうち無視する気がする...。

先日から「帰ってきたベイジアン」になったつもりが、こんな風に「頻度主義者の統計学」。節操がない訳ではありません、どちらにも興味があるのです。複数の視点があるのは良いことです。

そんな分析手法は、テキスト Workshop Statistics: Discovery with Data, A Bayesian Approach の序文には「statistical recipes 統計学レシピ」と評されている。そんな数多くのレシピの中心的存在が

Regression Analysis(回帰分析)

「回帰」なんて用語、日常ではまず聞かないし、クソ難しい響きがあるが、原理は意外と単純。難解な回帰分析方法もあるが、y = a + bx の(単純線形回帰)場合は難しくない。以下のチャートを、30 秒ほどじっと見つめていれば、何となく分かってくると思います。「何となく」で十分。
簡単にグラフを説明すると
  • 6 つの点が (x, y) の値
  • これらの点と最も近くにある直線が y = a + bx

「それだけなの?」という声も聞こえそうだが、概ね大丈夫。

分析例として、x を「1日の最高気温」、y を「ビールの売上本数」があるかもしれない(現実は知りません)。つまり、「最高気温が高いほどビールの売上も高い」と因果関係的にも納得できる様子を、y = a + bx という数値で表現(a, b には具体的な定数が入る)。

 「じゃ、明日の最高気温予想を見て、ビールの在庫調整に使えるね?」

Yes! とてもまっとうな発想です。それが、データ分析の目的である「モデルの構築」(y = a + bx を求めること)。

ところが、y = a + bx の単純線形回帰だけが回帰分析でない理由は、単に「単純線形回帰は使えない」という事実がある。「世の中、直線的な出来事ばかりではない」と、これも当たり前のこと。

補足2016年11月9日:参照「直線とロジスティック回帰:直線的でないのに直線回帰分析」。


OLS回帰分析の前提条件

とはいえ、この流れからこれ以降が「回帰分析の素晴らしさ」という話にはなりません。

「世の中、直線的な出来事ばかりではない」よりもっと深刻な

世の中(OLS)回帰分析で分かることばかりじゃない

というお話。

以降は、Robert I. Kabacoff R in Action: Data Analysis and Graphics With R を元にした。本書によれば「OLS Regression (OLS回帰分析)」とは

In this chapter, we’ll focus on regression methods that fall under the rubric of ordinary least squares (OLS) regression, including simple linear regression, polynomial regression, and multiple linear regression. OLS regression is the most common variety of statistical analysis today. Other types of regression models (including logistic regression and Poisson regression) will be covered in chapter 13. P.175
ロジスティック回帰分析、ポアソン回帰分析は「OLS回帰分析」に含まれませんが、今日では最も一般的な統計分析です。

次の引用は、OLS回帰分析の前提 です。つまり、分析対象のデータが、以下の4つの条件を満たさない場合、OLS 回帰分析ができないと言ってる。厳密には「やっても意味のない結果」ということ。

To properly interpret the coefficients of the OLS model, you must satisfy a number of statistical assumptions:
  • Normality—For fixed values of the independent variables, the dependent variable is normally distributed.
  • Independence —The Yi values are independent of each other.
  • Linearity—The dependent variable is linearly related to the independent variables.
  • Homoscedasticity—The variance of the dependent variable doesn't vary with the levels of the independent variables. We could call this constant variance, but saying homoscedasticity makes me feel smarter.

最初の3つはわかる。説明は冗長なので割愛するが、この辺が統計学の難解な側面の一つだろう。「データをポンと入れれば、チャランと答えが出る」にならないデータ分析の落とし穴 。


ホモとヘテロ
絶対、誰かは「違う」想像をする題にしてみました(笑)

今回の投稿のキッカケは、OLS 回帰分析ではなくて、先の前提の4番目

Homoscedasticity

私は「日本語より、英語の方が数学は理解しやすい」とのスタンスだが、この英単語には辟易した、「homo」以降は発音すら不可能。日本語は「等分散性」で、これも難解だが元の英語よりマシに見える。そんな「等分散性」と「Homoscedasticity」を Wikipedia で調べても、全く意味不明。

先の引用の説明
The variance of the dependent variable doesn't vary with the levels of the independent variables.

を何度も読み、「散らばり具合なのか?」と漠然とイメージできたが、それ以上は理解が深まらない。

そんな中 Homoscedasticity? Don't Be a Victim of Statistical Hippopotomonstrosesquipedaliophobia にある、以下の解説で一発で理解できた。


homo - scedasticity」は、ギリシャ語「homo + scedastic」の組み合わせで「same + to scatter」とのこと。つまり

同じ散らばり具合

Homoscedasticity ではない場合は Heteroscedasticityhetero とは other; different なので「異なる散らばり具合」ということ。上図の「グループAとCはホモ(て略したが、変な響き...)」「グループAとBはヘテロ」で更に納得。

要するに
同じ散らばり具合でない説明変数と被説明変数では、OLS回帰分析はできない

Statistics SolutionsHomoscedasticity の記事の heteroscedasticity の例が分かりやすい。概念的な意訳をしたが、原文が統計学的にちゃんと説明しているので、長いが引用した。
A simple bivariate example can help to illustrate heteroscedasticity: Imagine we have data on family income and spending on luxury items. Using bivariate regression, we use family income to predict luxury spending (as expected, there is a strong, positive association between income and spending). Upon examining the residuals we detect a problem – the residuals are very small for low values of family income (families with low incomes don’t spend much on luxury items) while there is great variation in the size of the residuals for wealthier families (some families spend a great deal on luxury items while some are more moderate in their luxury spending). This situation represents heteroscedasticity because the size of the error varies across values of the independent variable. Examining the scatterplot of the residuals against the predicted values of the dependent variable would show the classic cone-shaped pattern of heteroscedasticity.
「家計の収入金額」(説明変数)から「贅沢品の購入」(被説明変数)のOLS回帰分析を想定する。「収入と消費は強いプラスの相関関係」が期待できるので、分析可能と考える。しかし、ここには問題がある。まず、収入の低い家計の場合、贅沢品の消費は少ない。一方、高い収入の家計の場合、ある家計では大量に贅沢品を消費するが、別の家計ではソコソコの消費しかしない。この状況が heteroscedasticity で、散らばり具合は「典型的なトウモロコシ型」を示す。

原文では「residual(残差)の大小が違いすぎる」となっているが、これは「大金持ちとそうではない家計では、贅沢品の消費動向が違いすぎる」ということ。

長々と考えてこの結論、「当たり前だな」となった。でも納得感は高いので満足。

本来は、Homoscedasticity も含めて OLS 回帰分析の前提について、数学的に説明すべきなのかもしれない。残念ながら、今の私にはその能力がない。数学的な理解より、先ずは概念的な理解に努めた結果が今回の内容。この前提条件は、OLS 回帰分析するにあたって極めて重要だと思う。

今後「回帰分析」について、R in Action: Data Analysis and Graphics With R を元に書く予定。ただし、私にとって興味深い話題があればです。とはいえ「ベイジアン」にもっと取り組みたいのも本音。

0 件のコメント:

コメントを投稿