2016年3月3日木曜日

Metric 予測 by 複数 Metric:Predictor 追加の効果

掛算の効果(実装例)」からの続き。

本章末尾の Exercise 18.2 を行った。

以下は「お金で成績を買えるか?」で取り上げた図 18.1 
predictors xx に相関がないこのデータを、スクリプト Jags-Ymet-XmetMulti-Mrobust.R を次のように変更しながら分析する。

myData = read.csv( file="MultLinRegrPlotUnif.csv" )
yName = "y" ; xName = c("x1","x2")

パラメター推定の前に、データの相関関係を見る。

> library(GGally)
> ggpairs(myData)

プロット図から y と x2 に強い相関があり(0.85)、x1 と x2 には相関がない(0.00714)。y と x1 の相関 0.443 は弱いと判断する。

以下が推定結果。
係数の mode 値が、図 18.1 の回帰式 y ~ N(m, sd=2), m = 10 + 1x1 + 2xの係数と一致する。

次に、predictor を x1 のみにする

yName = "y" ; xName = c("x1")
Intercept10 から 20 へ、標準偏差(scale or σ)が 2 から 6 と大きく変化した。また Prop Var Accntd (the proportion of variance accounted for) の変化も大きい。

この結果は、以下の「本課題のポイント」の通り。
Here’s the point of the exercise: Notice that even when the predictors are uncorrelated, when you include the second predictor, you get a more precise estimate of the slope on the first predictor. 
相関のない predictors の場合でさえ、第 2 predictor を含めることで、第 1  predictor の係数の精度を高くできる。


データが少ない場合

以降では、同様の推定をデータを減らして行う。

myData = read.csv( file="MultLinRegrPlotUnif.csv" )
myData = myData[101:150,]
yName = "y" ; xName = c("x1","x2")

データ量は減ったが、相関は以下のようにほぼ同じ。
> ggpairs(myData)

以下が推定結果。
全データ使用の結果と比較して、95%HDI が広く

少ないデータの場合は推定は不確実

という結果。

さらに predictor を x1 のみにする。

myData = read.csv( file="MultLinRegrPlotUnif.csv" )
myData = myData[101:150,]
yName = "y" ; xName = c("x1")
x1 の係数の 95%HDI が 0 を含むという、かなり不確実な結果となった。これも、先の「本課題のポイント」の通り。

多変量解析は簡単じゃない」に続く。

0 件のコメント:

コメントを投稿