2018-06-18 統計モデリング入門 2018a 1/56
観測されたパターンを説明する統計モデル
久保拓弥 (北海道大・環境科学)
kubo@ees.hokudai.ac.jp
統計モデリング入門 2018 (a)
生物多様性学特論
An overview: Statistical Modeling
2018-06-18 統計モデリング入門 2018a 2/56
The main language of this class is
Japanese … Sorry
●
Why in Japanese? … because even in Japanese,
statistics is difficult
for Japanese students to
understand.
●
I will
compensate for language disadvantages
in foreign students when I give grades.
●Questions in English are always welcomed!
2018-06-18 統計モデリング入門 2018a 3/56
Performance Rating
●
E-mail assignment
(via Mailing List)
●That's ALL!
●
Attendance? NOT care.
2018-06-18 統計モデリング入門 2018a 4/56
この統計モデリング授業の
Mailing List (ML)
kubostat
●
ML を使って各回の「課題」を出します
●
回答もメイルで送信してください
●
Send your assignment via the class ML
●
成績評価は「課題」の回答
●出欠関係なし (欠席の連絡いりません)
●単位とらない人も ML 登録してください
●講義資料のダウンロード案内などあります
2018-06-18 統計モデリング入門 2018a 5/56統計モデリング授業の web page
http://goo.gl/76c4i
mailing list
http://goo.gl/f0vCn8
What for Statistical
Modeling?
なぜデータ解析の方法を
勉強しなければ
ならないのか?
All you depend on statistics
●
データ解析がおかしいと
結論もおかしい
●
Crazy data analsys → Crazy results
●
統計解析わからんと批判的に読めない
●
A lack of statistical knowledge →
no critical reading of papers
whenever you conclude something based on your data
データ解析はあまり重視されてなかった
●
ブラックボックス統計解析
●
No “Blackbox”statistics!
●
とにかく
「ゆーい差」
さえ出せばよいという
発想になっている
●
Don't blindly believe“Significance”!
2018-06-18 統計モデリング入門 2018a 9/56
この授業のねらい (aim)
●
Understand how to fit statistical models
to your data
データにあてはめられる統計
モデルを作ろう
●
Use the statistical software R to
show your data structure
できるだけ内容を理解して統計ソフトウェアを使おう!
教科書とソフトウェア
2018-06-18 統計モデリング入門 2018a 11/56この授業は「統計モデリング入門」
にそった内容を説明します
著者: 久保拓弥 出版社: 岩波書店 2012-05-18 刊行 価格 3990 円割引販売 3000 円!!
http://goo.gl/Ufq2
my text book (in Japanese)
2018-06-18 統計モデリング入門 2018a 12/56
統計ソフトウェア R
●無料で入手できる
●内容が完全に公開されている
●多くの研究者が使っている
●作図機能が強力
統計学の勉強には良い統計ソフトウェアが必要!
この教科書でも R を 使って問題を解決する 方法を説明していますStatistical software for this course
追記メモ:RStudio の紹介!
統計モデルとは何か?
What? statistical modeling?
2018-06-18 統計モデリング入門 2018a 14/56
「統計モデル」とは何か?
どんな統計解析においても
統計モデルが使用されている
●観察によってデータ化された
現象を説
明するため
に作られる
●確率分布
が基本的な部品であり,これ
はデータにみられるばらつきを表現す
る手段である
●データとモデルを対応づける手つづき
が準備されていて,モデルがデータに
どれぐらい良くあてはまっているかを
定量的に評価できる
「統計モデリング入門」の主張
「何でも正規分布」じゃないだろ!
GLM and extended GLMs!
Hierarchical Bayesian Model
Generalized Linear Mixed Model
Generalized
Linear Model
Linear Model
The Evolution of Linear Models
MSE MLE MCMC Parameter Estimation (GLM) (GLMM) (HBM)
a better statistica model for better
data analysis!
2018-06-18 統計モデリング入門 2018a 17/56
たとえばこんなデータがあったしましょう
体サイズ
種子数
An example
number of seeds
plant body size
2018-06-18 統計モデリング入門 2018a 18/56
一般化線形モデル - ばらつきをよく見る
0 個,1 個,2 個と数えられる種子数が
「正規分布」なわけないだろ!!
ポアソン分布 正規分布Don't use the normal distribution without seeing data!
第 1 回: 6/18 (月)
観測されたパターンを説明する統計モデル
Introduction
第 2 回: 6/18 (月)
確率分布と最尤推定
Probability Distributions and
Maximum Likelihood Estimation (MLE)
第 3 回: 6/25 (水)一般化線形モデル: ポアソン回帰
Generalized Linear Model (GLM):
Poisson Regression
全体の流れ (1/3)
第 4 回: 6/25 (月)
モデル選択と検定
Model Selection and Statistical Test
第 5 回: 7/02 (水)一般化線形モデル: ロジスティック回帰
GLM: Logistic Regression
第 6 回: 7/02 (月)階層ベイズモデル 1
Hierarchical Bayesian Models (HBM) 1
全体の流れ (2/3)
第 7 回: 7/09 (月)
繰り返し測定の階層ベイズモデル
Bayesian models for repeated measures
第 8 回: 7/09 (月)時間変化データのベイズ統計モデル
Bayesian models for Time series data
全体の流れ (3/3)
next: Kohyama-san’s Lecture
Plant Ecolgy
6/18
Overview
Statistical Modeling 2018 (b)
Probability distributions and
maximum likelihood estimation
さまざまな確率分布と最尤推定
単純化した例題
Simplified examples to learn statistical modeling
カウントデータはポアソン分布を
使って説明できないかを調べる
Find some
appropriate
probability
distributions
to fit the
observed
distributions
2018-06-18 統計モデリング入門 2018a 25/56
最尤推定という考えかたを説明します
さいゆう
How to fit the distribution to the observation?
Maximum likelihood estimation!
6/25
Overview
Statistical Modeling 2018 (c)
Poisson regression
and generalized linear model
ポアソン回帰と GLM
2018-06-18 統計モデリング入門 2018a 27/56ここで登場する
---「何でも正規分布」
ではダメ!
という発想
ポアソン分布 正規分布the“normal
distirbution is NOT
“normal”
2018-06-18 統計モデリング入門 2018a 28/56R
で統計モデリング
Free の統計
ソフトウェア
6/25
Overview
Statistical Modeling 2018 (d)
Model Selection
and Statistical Test
モデル選択と統計学的検定
2018-06-18 統計モデリング入門 2018a 30/56
Q. モデル選択とは何か?
statistical model selection
A. より
良い予測
をする統計モデルを探すこと
検定は モデル選択じゃない!
←こっちだ!
model selection for better predictions
統計学って「検定」のこと?
「検定」って何なの?
7/2
Overview
Statistical Modeling 2018 (e)
Logistic regression,
a generalized linear model
ロジスティック回帰
2018-06-18 統計モデリング入門 2018a 34/56
生物学のデータ解析は「割算」しまくり!!
mesurement / mesurement?… sounds bad!
2018-06-18 統計モデリング入門 2018a 35/56
GLM のひとつ,ロジスティック回帰を使おう
Use logistic regressions!
2018-06-18 統計モデリング入門 2018a 36/56
GLM のひとつ,ロジスティック回帰を使おう
a statistical model
for fractions
using binomial distributions
7/2
Overview
Statistical Modeling 2018 (f)
Hierarchical Bayesian model
and MCMC sampling
階層ベイズモデルと MCMC
2018-06-18 統計モデリング入門 2018a 38/56GLM ではうまく説明できないデータ!?
第 6 回と同じような例題を,こんどはベイズモデルを使ってモデリングしますGLM does NOT
work?!
GLM を階層ベイズモデル化して対処
A solution: Hierarchical Bayesian GLM
なぜ階層ベイズモデルまで勉強するの?
Hierarchical Bayesian Model Generalized Linear Mixed Model
Generalized Linear Model
Linear Model The Evolution of Linear Models
MSE MLE MCMC Parameter Estimation (GLM) (GLMM) (HBM) ●
生態学!
✔個体差・エリア差・空間相関・
時間相関・種差などめんどうな
ことをあつかわないといけない
What for hierarchical Bayesian
modeling? --- to detect interesting
effects embedded in noisy & dirty
data in the field of Ecology!
第 7, 8 回は
「時間変化」するデータ
の統計モデリング
(階層ベイズモデルの応用)
Modeling of time-series data as
an application of hierarchical
Bayesian modeling!
7/9
Overview
Statistical Modeling 2018 (g)
Modeling time change data
(short term)
短い時系列データの統計モデル
短い時系列データ
時系列の長短に関係なく
「対応のある」
データ点か
どうかが本質的な問題
A Time series model
for single step data
2018-06-18 44/56
再測定もまた時系列データ
岩波データ
サイエンス
vol.1
架空
データ
2018-06-18 45/56対応 (paired) を考えてない GLM あてはめ
glm(身長 〜 (測定2回目) + (測定2回目):
(処理の効
果)
)
これはまちがい!
同じ対象を二回測定していることを考慮してない
「ゆーい差」
あり,となる
2018-06-18 46/56対応 (paired) を考えてない GLM あてはめ
glm(身長 〜 (測定2回目) + (測定2回目):
(処理の効
果)
)
これはまちがい!
同じ対象を二回測定していることを考慮してない
「ゆーい差」
あり,となる
「ゆーい」に
なりやすい
2018-06-18 47/56対応 (paired) を考慮し,
さらに県の差もあるモデル
給食効果な
し
7/9
Overview
Statistical Modeling 2018 (h)
Modeling time series data
(long term)
7/27 (水)
2018-06-18 統計モデリング入門 2018a 50/56時間相関のある時系列データに…
glm(y ~ t)
…と,モデルを
あてはめてみた
y
t
time series data and autocorrelation
2018-06-18 統計モデリング入門 2018a 51/56
「やったー
ゆーい
だ!!」……??
これはまちがい→
> summary(glm(formula = y ~ t))
Deviance Residuals:
Min 1Q Median 3Q Max
-2.1295 -1.0583 -0.0817 0.9860 2.0188
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -414.5655 71.4761 -5.80 6.6e-06
t 0.2339 0.0357 6.55 1.1e-06
glm(時系列Y ~ 時間 t)
統計モデルがおかしい?
A fake significance
2018-06-18 統計モデリング入門 2018a 52/56時系列の「ずれ」
GLM のずれ
直線からのずれがちがう!
時間的自己相関がある
時間的自己相関がない
independent noises
temporal
autocorrelation
統計モデルづくりの要点
時系列データの解析は
階層ベイズモデル化した
状態空間モデル
を使うのが便利
Latent state model is a better model to know the
characteristics of time-series data
2018-06-18 統計モデリング入門 2018a 54/56