Multicollinearity on multiple dependent variables

36 views Asked by At

Consider the following:

library(tidyverse)
library(car)

a <- c( 2, 3, 4, 5, 6, 7, 8, 9, 100, 11)
b <- c(5, 6, 7, 80, 9, 10, 11, 12, 13, 14)
c <- c(15, 16, 175, 18, 19, 20, 21, 22, 23, 24)

x <- c(17,18,50,15,64,15,3,5,6,9)
y <- c(55,66,99,83,64,51,23,64,89,101)
z <- c(98,78,56,21,45,34,61,98,45,64)

abc <- data.frame(cbind(a,b,c))

Firstly, I run a regression and values abc with xyz as follows (This went according to plan):

dep_vars <- as.matrix(abc)
lm <- lm(dep_vars ~ x + y + z, data = abc)

From here, I want to get the variance inflation factor using the vif() function:

vif(lm)

But then I get an error that says Error in if (names(coefficients(mod)[1]) == "(Intercept)") { : argument is of length zero. Can anybody help me understand where I went wrong? Or is there an alternative?

0

There are 0 answers