VIF: 'VIF' function for assessing VIF.

Description Usage Arguments Value Methods (by class) Note See Also Examples

View source: R/VIF.R

Description

VIF measure how much the variance of the estimated regression coefficients are inflated. It helps to identify when the predictor variables are linearly related. You have to decide which variable should be delete. Values higher than 10 signal a potential collinearity problem.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
VIF(x, posit_y, posit_x, correct = FALSE)

## S3 method for class 'data.frame'
VIF(x, posit_y, posit_x, correct = FALSE)

## S3 method for class 'data.table'
VIF(x, posit_y, posit_x, correct = FALSE)

## S3 method for class 'matrix'
VIF(x, posit_y, posit_x, correct = FALSE)

Arguments

x

a numeric matrix or data.frame/data.table (factor/character/numeric) - variables

posit_y

an integer/character - a position/name of dependent variable

posit_x

an integer/character vector - positions/names of independent variables

correct

a boolean - basic or corrected - Default: FALSE

Value

load a numeric vector with VIF for all variables provided by posit_x

Methods (by class)

Note

vif_corrected = vif_basic^(1/(2*df))

See Also

fill_NA fill_NA_N

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
library(miceFast)
library(data.table)

airquality2 <- airquality
airquality2$Temp2 <- airquality2$Temp**2
# install.packages("car")
# car::vif(lm(Ozone ~ ., data=airquality2))

data_DT <- data.table(airquality2)
data_DT[, .(vifs = VIF(
  x = .SD,
  posit_y = "Ozone",
  posit_x = c("Solar.R", "Wind", "Temp", "Month", "Day", "Temp2"),
  correct = FALSE
))][["vifs"]]

data_DT[, .(vifs = VIF(
  x = .SD,
  posit_y = 1,
  posit_x = c(2, 3, 4, 5, 6, 7),
  correct = TRUE
))][["vifs"]]

## End(Not run)

miceFast documentation built on July 11, 2021, 1:06 a.m.