2016年2月26日金曜日

Metric 予測 by 複数 Metric:掛算の効果(実装例)

掛算の効果」からの続き。

multiplicative interaction を含むモデルの実装として、ここでは interaction がないモデルに「単に追加したモデル」を検討する。つまり

μ = β0 + β1x1 β2xβ1×2 x1x2

のモデルに、ββ1×2 , x3 = x1x2 変数を加える。スクリプト Jags-Ymet-XmetMulti-Mrobust-Exaple.R への変更点は以下の行

 myData = read.csv( file="Guber1999data.csv" )
 yName = "SATT" ; xName = c("Spend","PrcntTake")

の後に、SpendXPrcnt= Spend × PrcntTake)を追加。

 myData = cbind( myData , SpendXPrcnt=myData[,"Spend"]*myData[,"PrcntTake"] )
 yName = "SATT" ; xName = c("Spend","PrcntTake","SpendXPrcnt")



次はスクリプトの実行結果から、predictors の相関具合。

             Spend PrcntTake SpendXPrcnt
Spend       1.000     0.593       0.775
PrcntTake   0.593     1.000       0.951
SpendXPrcnt 0.775     0.951       1.000

interaction 変数 SpendXPrcnt Spend, PrcntTake と強い相関がある。その結果、interaction のない場合と比較して、以下は実行結果(図18.9 の上段に相当)では β1β2 が幅の広い分布を示している(「冗長なモデル」ということ?? 保留とする)。
上手から注目すべきは点は

  • SpeedXPrcnt の係数が 95%HDI[0.0592, 0.466] で「0 を含む」
  • Sepnd の係数が 95%HDI[-13.5, 17.8] で「0 を含む」


他の predictor が zero の前提

Spend の係数の区間推定で 0 を含んでいることから、「コストはSAT スコアに影響しない」という結論は誤り。

μ = β0 + β1x1 β2xβ1×2 x1x2

β1 only indicates the slope on spending when the percentage of students taking the test is zero. 
β1 は、PrcntTake = 0 (テストの受験率が 0 )の場合の「コスト Spend」係数にすぎない。
The slope on Spend depends on the value of PrcntTake because of the interaction. 
interaction のために、Spend の係数は PrcntTake に依存する。

前回の解説の通り μ = β0 + β1x1 β2xβ1×2 x1x2 は

μ = β0 + (β1 β1×2 x2)x1 β2x2
    = β0  β1x+ (β2 β1×2 x1)x2

のように、各 predictor からの見方ができる。つまり、Spend の係数は (β1 + β1×2 x2)  =  (β1 + β3 PrcntTake) のように PrcntTake に依存する。

これを視覚化したのが以下の図18.9 の下段。
この上段が「Spend の係数と PrcntTake 値」で、係数の分布を中央値と 95%HDI で示したもの。PrcntTake が大きい場合(約 40 以上)、係数は 0 を含まない。PrcntTake が 0 の時の係数は、図18.9 上段の Spend 係数の 95%HDI[-13.5, 17.8] を示す。これが、先に引用した

β1 only indicates the slope on spending when the percentage of students taking the test is zero. 

の意味。

同様に、PrcntTake の係数は(β2 + β1×2 x1)  =  (β2 + β3 Spend) のように Spend への依存は、上図下段の通り。


スッキリしない理由

Spend と PrcntTake の係数の HDI0 を含む場合でも、predictors を無視できないことは理解できた。ただ、SpendXPrcntTake の係数が 0 の場合の結論はよく分かっていない。

なので、今回の結論は、本節の末尾をそのまま引用する。

In summary, when there is interaction, then the influence of the individual predictors can not be summarized by their individual regression coefficients alone, because those coefficients only describe the influence when the other variables are at zero. A careful analyst considers credible slopes across a variety of values for the other predictors, as in Figure 18.9. Notice that this is true even though the interaction coefficient did not exclude zero from its 95% HDI. In other words, if you include an interaction term, you cannot ignore it even if its marginal posterior distribution includes zero.

個人的に何がスッキリしないかのといえば、「interaction の可否の判断方法」が不明なこと。つまり、SpendXPrcntTake を導入したモデルは、導入前よりも有効なのかということ。複数の predictors は、いつでも interaction すべきではない。冒頭の「薬の効用」「幸福度」の例のように、interaction している predictors かの判断が必要。

この疑問へは、本書の後の節にあるはずなので、そこで対応したい。

Predictor 追加の効果」に続く。

0 件のコメント:

コメントを投稿