3. この章では
• ひとつの観測値からある観測値を予測する事を
行う
o 体重の予測を身長から
o 血圧を体重から
o 収入を教育された年数から
• これからxとyを、単純な線形モデルで表す
o yは残余値(予測モデルと実測値の差)が正規分布していると
する
• 一般化線形モデルで表すと
o 仮定:
o モデル:
o これをSimple Linear Regression(線形単回帰)と通常呼ぶ
ng a person’s weight from their
ght, or predicting their income
variable is metric and the single
etween the predicted variable, y,
distributed residual randomness
model assumes that y ∼ N(µ,τ)
312) in the first row and second
gression”.
h R and BUGS. Academic Press /
The agri-bank’s threatnin’ to revoke my lease
If my field’s production don’t rapid increase.
Oh Lord how I wish I could divine the trend,
Will my furrows deepen? and Will my line end?
In this chapter we consider situations such as predictin
height, or predicting their blood pressure from their weig
from years of education. In these situations, the predicted v
predictor is also metric. We will describe the relationship be
and predictor, x, with a simple linear model and normally d
in y. In terms of the generalized linear model (GLM), the m
with µ = β0 + β1x. This model appears in Table 14.1 (p. 3
column. This model is often referred to as “simple linear reg
Kruschke, J. K. (2010). Doing Bayesian Data Analysis: A Tutorial with
4. はじめに
• 既に皆さんも線形回帰は何度もやってきたと思
います
• 僕が習ってきたものは
o yとxに線形の関係があって、全てのデータは同じ分散の正
規分布によるエラーがあるとしましょう
o あ、そうすると最小二乗法が使えますね
o 偏微分すれば簡単に回帰の傾きと切片が出せますね
o R2値…Excel/統計ソフトでの計算方法…
• ここでは
o 回帰式の傾きの95%信頼区間
o あるxを与えた時のyの分布
o 外れ値の扱い
→より確率を使った議論
5. 線形単回帰
• このモデルでは、yがxに従属であることしか
言っていない
o xがどのように生まれるか、xの値の確率分布については何
も言っていない。
o 下図でも左はxの一様分布、右は双峰性の分布。
and predictor, x, with a simple linear mode
in y. In terms of the generalized linear mod
with µ = β0 + β1x. This model appears in
column. This model is often referred to as “
Kruschke, J. K. (2010). Doing Bayesian Data Analy
Elsevier. Copyright c 2010 by John K. Kruschke
preliminary draft. If you report Bayesian analyses b
14. 正規化の方法
• データを移動させてやれば解決できる
• 平均を引いて、標準偏差で割ればいい
o こうすると簡単に平均0、標準偏差が1のデータが作れる
• 正規化した式を元のβに戻すと…
16.2. There you can see various believable lines that go through the scatter of points.
tice that if a line has a steep slope, its intercept must be low, but if a line has a smaller
pe, its intercept must be higher. Thus, there is a trade-off in slope and intercept for the
ievable lines.
One of the main tricks used for successful execution of the MCMC sampling is stan-
dizing the data. Standardizing simply means re-scaling the data relative to their mean
standard deviation:
z(x) =
(x − Mx)
SDx
and z(y) =
y − My
SDy
(16.1)
ere Mx is the mean of the data x values and SDx is the standard deviation of the data x
ues. (Do not confuse Mx and My with the constants used in the specification of the priors
he hierarchical diagram.) It is easy to prove, using simple algebra, that the mean of the
ulting z(x) values is zero, and the standard deviation of the resulting z(x) values is one,
any initial data set.
Having used BUGS to find slope and intercept values for the standardized data, we then
d to convert the parameter values back to the original raw scales. Denote the intercept
slope for standardized data as ζ0 and ζ1 (Greek letter “zeta”), and denote the predicted
ue of y as ˆy. Then:
zˆy = ζ0 + ζ1zx by definition of the model
z(x) =
(x − Mx)
SDx
and z(y) =
y − My
SDy
(16.1)
ere Mx is the mean of the data x values and SDx is the standard deviation of the data x
ues. (Do not confuse Mx and My with the constants used in the specification of the priors
the hierarchical diagram.) It is easy to prove, using simple algebra, that the mean of the
ulting z(x) values is zero, and the standard deviation of the resulting z(x) values is one,
any initial data set.
Having used BUGS to find slope and intercept values for the standardized data, we then
ed to convert the parameter values back to the original raw scales. Denote the intercept
d slope for standardized data as ζ0 and ζ1 (Greek letter “zeta”), and denote the predicted
ue of y as ˆy. Then:
zˆy = ζ0 + ζ1zx by definition of the model
ˆy − My
SDy
= ζ0 + ζ1
(x − Mx)
SDx
from Eqn. 16.1
ˆy = ζ0SDy + My − ζ1SDyMx/ SDx
β0
+ ζ1SDy/ SDx
β1
x (16.2)
us, for every believable combination of ζ0,ζ1 values, there is a corresponding believable
20. yのHDIと事後確率予測350 CHAPTER 16. METRIC Y, ONE METRIC X
60 65 70 75
50100150200250300
Data with 95% HDI & Mean of Posterior Predictions
X (height in inches)
Y(weightinpounds)
+ + + + + + + + + + + + + + + + + + + + + + + +
Figure 16.6: Data points, with 95% HDIs and means of posterior predictions in y,
at selected x values. The HDIs are wider (i.e., taller) for extrapolated x values than
• 灰色のラインが
95%HDI
• ダッシュがyの事後確
率予測の平均
• 真ん中の方が灰色の
線が短く、両サイド
は大きい
• データが多いところ
より尐ないところの
ほうが信頼度が尐な
いのでHDIの範囲が大
きくなる
22. 外れ値と頑健な回帰
• 標準尤度関数は外れ値によって大きくねじ曲げ
られてしまう(→15章 図15.5)
o 回帰分析の場合も同じことが起きる。
o 標準尤度関数は回帰線からデータのポイントが縦方向に近
いことを要求する→尤度は標準偏差x3より離れた点に対し
て非常に小さい値になってしまうため
o よって外れ値は回帰の傾きに大きく影響を与えすぎること
がある
• 正規分布→t分布
o 正規分布はt分布における自由度(df)無限大と同じ。t分布
でdfが小さいものは、ロングテールになっている
o t分布は、データが尐ない時の不確実性を表している。ロ
ングテールになっているため、外れ値を正規分布よりは”
ありうる”値として受容する
25. 繰返しの測定と単回帰
• 個々のデータjにそれぞれの観測値xij,yijがあった
とする。
o これらそれぞれにモデルを作ることが出きる
o これら個々が同じグループに属しているとして、グループ
レベルのパラメータを算出することを考える
• ラットに薬物(酸化鉄イオン?)を与える実験
o 肝臓での分解によって血中濃度が時系列でどのように減っ
ていくかを単回帰してみる。
o それぞれの観測結果も試行ごとに誤差がでる(いままでも
これはあった)
o それぞれのラットで減り方は異なる
o グループとしての減る割合はどれくらいか?個体差はどれ
くらいと見積もれるか?