3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

glmer/lmerで信頼区間を算出する方法

Last updated at Posted at 2018-01-02

ご挨拶

R + RStudioの自己学習の成果を自分へのメモも兼ねて遺していきます。
不正確な点には生暖かくご指摘を下さい。

背景

Rで頻度論のglmmを実行する際、lme4パッケージのlmer関数またはglmer関数が頻用されます。
glmmML等の他の関数と比較すると、複数のランダム変数を扱えることがメリット。その一方で、PQRを用いるために、ガウス求積を用いるglmmMLやSASと比べて推定が正確じゃないことがデメリットとされます。

そんなlme4 (lmer/glmer) の実用上の問題は、95%信頼区間 (CI) をデフォルトでは算出してくれないこと。glm関数ではconfint関数を使いますが、lmer/glmerではオブジェクト型が異なるのでconfint関数が動きません。lme4パッケージには代替の関数が準備されています。

confint.merMod関数

それがこのconfint.merMod関数。.以降のmerModはlmer/glmerで生成されるオブジェクト型の名前です。

S3 method for class 'merMod'

confint(object, parm, level = 0.95,
method = c("profile", "Wald", "boot"), zeta,
nsim = 500,
boot.type = c("perc","basic","norm"),
FUN = NULL, quiet = FALSE,
oldNames = TRUE, ...)

levelで信頼水準を指定し、methodで信頼係数の算出法を指定します。理想はmethodにbootを指定し、bootstrapで信頼区間を算出することです。が、ここがひとつ、躓きポイントになります。

methodにprofileかbootを指定した場合、きちんと収斂する良いモデルでないとエラーを吐き続けます。サンプルサイズが小さかったり、モデルが特定できなかったりすると、profileやbootでは信頼係数を算出できません。そういう場合でもWaldなら算出できますけど、その時点でモデルの筋が悪いことが判明しているので、Wald使って算出した信頼区間を信頼してよいかは甚だ怪しいところ。モデルの素性もよろしくないと想定されるので、モデル、特にランダム変数周りをシンプルにしてあげると良いような (経験論ですが)。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?