1

R で VIF (Variance Inflation Factors、回帰の変数間の共線性を検出するため) を計算する一般的な方法は 2 つあります。

  1. 入力がモデルであるパッケージ内のvif()関数。これには、モデル内の変数間の VIF をチェックする前に、まずモデルを適合させる必要があります。car

  2. 入力が実際のcorvif()候補説明変数 (つまり、モデルが適合される前の変数のリスト) である関数。この機能は、AED廃止されたパッケージ (Zuur et al. 2009) の一部です。これは、当てはめられた回帰モデルではなく、変数のリストでのみ機能するようです。

以下はデータの例です。

MyData<-structure(list(site = structure(c(3L, 1L, 5L, 1L, 2L, 3L, 2L, 
4L, 1L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 4L, 1L, 1L, 3L, 3L, 1L, 4L, 
3L, 1L, 3L, 4L, 5L, 1L, 3L, 1L, 2L, 4L, 2L, 1L, 1L, 5L, 3L, 1L, 
3L, 4L, 3L, 1L, 4L, 4L, 2L, 5L, 2L, 1L, 4L, 1L, 1L, 1L, 4L, 4L, 
3L, 5L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 4L, 5L, 1L, 5L, 1L, 4L, 1L, 
4L, 1L, 2L, 5L, 2L, 3L, 1L, 5L, 4L, 1L, 1L, 3L, 2L, 1L, 3L, 5L, 
3L, 3L, 5L, 2L, 1L, 3L, 5L, 4L, 5L, 5L, 1L, 3L, 2L, 5L, 4L, 3L, 
3L, 2L, 5L, 2L, 1L, 1L, 3L, 3L, 5L, 5L, 5L, 3L, 1L, 1L, 5L, 5L, 
5L, 2L, 3L, 5L, 1L, 3L, 3L, 4L, 4L, 4L, 5L, 2L, 3L, 1L, 4L, 2L, 
4L, 3L, 4L, 3L, 3L, 4L, 1L, 3L, 4L, 1L, 4L, 4L, 5L, 4L, 4L, 1L, 
4L, 1L, 2L, 1L, 2L, 4L, 2L, 4L, 3L, 5L, 1L, 2L, 3L, 1L, 1L, 4L, 
3L, 1L, 1L, 1L, 4L, 3L, 5L, 4L, 2L, 1L, 4L, 1L, 2L, 1L, 1L, 5L, 
1L, 5L, 3L, 1L, 5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, 5L, 1L, 
    3L, 2L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 
    4L, 4L), .Label = c("East", "Flat", "North", "South", "West"
    ), class = "factor"), height = c(515L, 60L, 60L, 30L, 70L, 
    70L, 40L, 70L, 50L, 75L, 160L, 85L, 40L, 90L, 70L, 210L, 
    30L, 60L, 45L, 60L, 410L, 50L, 40L, 210L, 140L, 120L, 70L, 
    35L, 30L, 90L, 40L, 240L, 40L, 55L, 120L, 200L, 65L, 40L, 
    95L, 140L, 220L, 70L, 40L, 30L, 50L, 95L, 50L, 50L, 50L, 
    70L, 160L, 45L, 35L, 50L, 70L, 230L, 110L, 300L, 50L, 105L, 
    60L, 50L, 60L, 70L, 30L, 60L, 30L, 110L, 80L, 80L, 30L, 60L, 
    70L, 80L, 60L, 40L, 220L, 140L, 110L, 40L, 40L, 40L, 90L, 
    125L, 90L, 100L, 270L, 420L, 60L, 70L, 53L, 40L, 80L, 90L, 
    30L, 40L, 65L, 40L, 110L, 90L, 40L, 190L, 110L, 70L, 52L, 
    120L, 95L, 50L, 50L, 140L, 75L, 30L, 50L, 60L, 125L, 60L, 
    80L, 35L, 55L, 140L, 140L, 240L, 65L, 40L, 200L, 80L, 60L, 
    65L, 120L, 80L, 230L, 150L, 40L, 50L, 60L, 210L, 50L, 130L, 
    140L, 210L, 60L, 50L, 90L, 120L, 55L, 50L, 20L, 50L, 40L, 
    70L, 40L, 100L, 80L, 85L, 60L, 50L, 20L, 200L, 40L, 70L, 
    50L, 200L, 60L, 43L, 30L, 60L, 40L, 70L, 40L, 40L, 40L, 50L, 
    110L, 70L, 30L, 50L, 85L, 70L, 40L, 100L, 40L, 50L, 100L, 
    40L, 70L, 40L, 40L, 50L, 210L, 50L, 140L, 80L, 75L, 90L, 
    40L, 50L, 60L, 50L, 80L, 50L, 60L, 40L, 60L, 170L, 60L, 80L, 
    80L, 15L, 40L, 70L, 45L, 45L, 45L, 110L, 200L, 30L, 60L, 
    40L, 60L, 160L, 40L, 90L, 80L, 30L, 40L, 270L, 50L, 50L, 
    60L, 60L, 50L, 30L, 70L, 170L, 50L, 30L, 50L, 60L, 40L, 60L, 
    60L, 140L, 80L, 80L, 220L, 45L, 80L, 130L, 50L, 40L, 220L, 
    40L, 70L, 60L, 80L, 50L, 200L, 115L, 50L, 90L, 400L, 50L, 
    360L, 40L, 60L, 60L, 65L, 100L, 50L, 55L, 60L, 50L, 130L, 
    40L, 130L, 40L, 40L, 120L, 66L, 55L, 100L, 75L, 60L, 80L, 
    60L, 90L, 160L, 50L, 210L, 35L, 60L, 40L, 55L, 50L, 90L, 
    220L, 60L, 120L, 62L, 60L, 40L, 60L, 70L, 60L, 90L, 50L, 
    50L, 30L, 110L, 70L, 80L, 90L, 210L, 70L, 65L, 160L, 100L, 
    25L, 55L, 40L, 60L, 110L, 70L, 50L, 60L, 70L, 60L, 60L, 170L, 
    45L, 60L, 120L, 40L, 60L, 130L, 40L, 170L, 50L, 80L, 60L, 
    150L, 90L, 60L, 120L, 120L, 80L, 30L, 110L, 230L, 190L, 70L, 
    110L, 50L, 60L, 82L, 60L, 30L, 60L, 200L, 90L, 30L, 140L, 
    60L, 70L, 70L, 100L, 60L, 415L, 115L, 90L, 60L, 60L, 80L, 
    60L, 55L, 90L, 65L, 60L, 40L, 40L, 90L, 50L, 70L, 70L, 120L, 
    40L, 50L, 110L, 45L, 30L, 95L, 30L, 70L), width = c(310L, 
    50L, 40L, 30L, 60L, 70L, 20L, 80L, 70L, 20L, 220L, 40L, 60L, 
    30L, 230L, 110L, 20L, 40L, 25L, 60L, 240L, 90L, 30L, 130L, 
    120L, 110L, 60L, 70L, 30L, 110L, 30L, 180L, 20L, 80L, 110L, 
    310L, 40L, 10L, 80L, 160L, 134L, 30L, 20L, 40L, 20L, 230L, 
    100L, 180L, 40L, 120L, 130L, 30L, 40L, 100L, 30L, 180L, 70L, 
    110L, 170L, 40L, 30L, 50L, 30L, 40L, 30L, 50L, 80L, 50L, 
    80L, 90L, 70L, 70L, 190L, 60L, 50L, 30L, 150L, 150L, 50L, 
    80L, 30L, 40L, 130L, 390L, 60L, 130L, 400L, 200L, 110L, 30L, 
    15L, 300L, 70L, 140L, 30L, 50L, 30L, 40L, 110L, 240L, 50L, 
    90L, 70L, 20L, 40L, 100L, 50L, 30L, 30L, 130L, 40L, 70L, 
    70L, 60L, 10L, 30L, 60L, 50L, 40L, 120L, 90L, 210L, 50L, 
    20L, 100L, 100L, 110L, 100L, 100L, 80L, 120L, 80L, 5L, 40L, 
    50L, 60L, 15L, 100L, 120L, 200L, 30L, 80L, 60L, 70L, 30L, 
    30L, 20L, 50L, 50L, 60L, 15L, 80L, 60L, 130L, 40L, 60L, 30L, 
    100L, 20L, 130L, 60L, 120L, 70L, 20L, 60L, 20L, 40L, 50L, 
    15L, 120L, 60L, 50L, 300L, 40L, 30L, 25L, 70L, 130L, 30L, 
    50L, 60L, 50L, 50L, 50L, 20L, 30L, 70L, 35L, 180L, 40L, 50L, 
    70L, 40L, 70L, 50L, 20L, 40L, 40L, 40L, 40L, 50L, 20L, 30L, 
    180L, 30L, 130L, 30L, 15L, 25L, 50L, 40L, 40L, 40L, 50L, 
    170L, 20L, 50L, 20L, 50L, 110L, 30L, 90L, 15L, 50L, 40L, 
    150L, 30L, 30L, 30L, 20L, 40L, 20L, 100L, 60L, 40L, 30L, 
    30L, 140L, 40L, 50L, 120L, 150L, 100L, 70L, 300L, 30L, 60L, 
    120L, 30L, 50L, 100L, 60L, 90L, 50L, 40L, 140L, 130L, 60L, 
    60L, 70L, 200L, 30L, 40L, 50L, 20L, 20L, 20L, 80L, 35L, 70L, 
    15L, 40L, 360L, 70L, 50L, 50L, 30L, 110L, 30L, 30L, 90L, 
    50L, 30L, 70L, 40L, 110L, 70L, 40L, 150L, 100L, 40L, 40L, 
    40L, 20L, 250L, 180L, 40L, 60L, 20L, 120L, 40L, 50L, 60L, 
    260L, 110L, 30L, 30L, 40L, 100L, 50L, 50L, 100L, 150L, 190L, 
    70L, 110L, 50L, 10L, 40L, 50L, 60L, 80L, 30L, 20L, 150L, 
    70L, 25L, 30L, 40L, 50L, 30L, 50L, 210L, 40L, 100L, 30L, 
    80L, 20L, 30L, 70L, 130L, 60L, 50L, 50L, 70L, 50L, 30L, 150L, 
    130L, 110L, 50L, 40L, 80L, 90L, 40L, 40L, 40L, 40L, 200L, 
    140L, 40L, 25L, 50L, 50L, 40L, 20L, 40L, 340L, 70L, 60L, 
    50L, 20L, 80L, 60L, 25L, 260L, 20L, 15L, 40L, 30L, 300L, 
    120L, 60L, 100L, 50L, 40L, 20L, 90L, 50L, 40L, 80L, 30L, 
    40L), length = c(450L, 80L, 55L, 50L, 90L, 90L, 30L, 90L, 
    90L, 30L, 240L, 50L, 70L, 40L, 380L, 200L, 40L, 40L, 35L, 
    110L, 250L, 120L, 70L, 150L, 130L, 140L, 90L, 90L, 40L, 390L, 
    40L, 190L, 40L, 110L, 140L, 360L, 50L, 30L, 130L, 500L, 200L, 
    30L, 25L, 60L, 30L, 350L, 110L, 180L, 70L, 180L, 200L, 40L, 
    70L, 110L, 70L, 180L, 90L, 150L, 400L, 100L, 60L, 70L, 70L, 
    60L, 30L, 50L, 80L, 180L, 110L, 100L, 110L, 110L, 210L, 80L, 
    70L, 40L, 500L, 210L, 50L, 80L, 40L, 50L, 350L, 400L, 150L, 
    200L, 400L, 280L, 240L, 40L, 50L, 360L, 140L, 140L, 50L, 
    50L, 40L, 50L, 210L, 370L, 70L, 110L, 80L, 50L, 50L, 100L, 
    80L, 50L, 35L, 140L, 60L, 90L, 110L, 60L, 130L, 180L, 70L, 
    70L, 40L, 230L, 130L, 290L, 90L, 40L, 100L, 100L, 120L, 150L, 
    110L, 80L, 220L, 90L, 5L, 50L, 50L, 60L, 30L, 150L, 120L, 
    200L, 60L, 170L, 80L, 90L, 40L, 50L, 70L, 50L, 60L, 100L, 
    15L, 90L, 70L, 150L, 60L, 90L, 50L, 120L, 20L, 220L, 80L, 
    140L, 120L, 30L, 60L, 40L, 40L, 70L, 30L, 180L, 60L, 110L, 
    300L, 50L, 60L, 50L, 110L, 160L, 40L, 70L, 70L, 60L, 70L, 
    50L, 25L, 30L, 215L, 70L, 220L, 70L, 80L, 90L, 60L, 130L, 
    60L, 20L, 60L, 50L, 40L, 60L, 100L, 40L, 70L, 210L, 40L, 
    500L, 40L, 30L, 50L, 80L, 40L, 60L, 80L, 50L, 220L, 20L, 
    70L, 50L, 50L, 180L, 50L, 90L, 15L, 120L, 80L, 170L, 30L, 
    30L, 60L, 20L, 60L, 30L, 140L, 80L, 40L, 50L, 40L, 200L, 
    80L, 80L, 120L, 160L, 210L, 120L, 400L, 60L, 60L, 180L, 70L, 
    70L, 150L, 70L, 110L, 70L, 80L, 250L, 140L, 90L, 60L, 180L, 
    400L, 60L, 50L, 60L, 40L, 30L, 50L, 100L, 40L, 110L, 30L, 
    80L, 400L, 70L, 50L, 80L, 30L, 180L, 70L, 60L, 100L, 70L, 
    50L, 100L, 60L, 220L, 70L, 70L, 200L, 110L, 50L, 110L, 50L, 
    60L, 250L, 220L, 60L, 80L, 35L, 210L, 70L, 70L, 110L, 320L, 
    280L, 60L, 50L, 60L, 100L, 70L, 70L, 170L, 170L, 230L, 80L, 
    130L, 90L, 10L, 60L, 70L, 60L, 120L, 40L, 50L, 160L, 100L, 
    30L, 40L, 40L, 90L, 30L, 80L, 240L, 100L, 170L, 60L, 120L, 
    20L, 40L, 70L, 150L, 80L, 50L, 90L, 130L, 70L, 60L, 480L, 
    150L, 130L, 90L, 70L, 150L, 100L, 70L, 50L, 40L, 60L, 400L, 
    200L, 80L, 30L, 120L, 70L, 50L, 40L, 40L, 360L, 90L, 70L, 
    60L, 40L, 110L, 80L, 25L, 270L, 40L, 25L, 50L, 30L, 320L, 
    150L, 100L, 100L, 60L, 40L, 50L, 100L, 50L, 50L, 200L, 30L, 
    80L), ground = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    2L, 1L, 2L, 1L, 1L, 1L, 1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 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 
    0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 
    0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 
    1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 
    0L)), .Names = c("site", "species", "aspect", "height", "width", 
"length", "ground", "sun", "leaf", "Presence"), row.names = c(NA, 
393L), class = "data.frame")

モデルの選択後、これが最適なモデルです。

model <- glm(Presence ~ site + species + aspect + length + sun 
            + leaf, data=MyData, family=binomial)

上記の最初の方法に関しては、次のことができます。

library(car)
vif(model)

入力としてモデルに基づいて VIF を取得します。

しかし、2 番目の方法に関しては、モデルを適合させる前に、変数の VIF を調べることができます。

library(AED) # note that his package has been discontinued
vars <- cbind(MyData$site, MyData$species,
MyData$aspect , MyData$length ,
MyData$width, MyData$height,
MyData$ground, MyData$sun, MyData$leaf)
corvif(vars)

(corvif()関数コードはここにあります: http://www.highstat.com/Book2/HighstatLibV6.R )

2 つの関数の基礎となる数学は同じように見えますが、関数が記述されている方法では、異なるタイプのオブジェクトを入力として受け入れます。

私の質問は次のとおりです。

  1. VIF をベースに計算しますか?

    1. モデルフィッティング前の変数のリストで、
    2. 適合モデル、または
    3. 両方?
  2. 人々が VIF を計算するために推奨および/または使用する関数はありますか (既に言及した 2 つに加えて)?

  3. 入力のように、変数のリストと適合モデルの両方で機能する単一の R 関数を知っている人はいますか?

4

1 に答える 1