I have a linear regression model (let’s say called “reg”) which includes an interaction variable. Ultimately, I want to calculate the variance inflation factors to check for multicollinearity.
I wanted to this by car::vif. As suggested, since there is an interaction variable, I am setting type = “predictor”.
However, when I run this:
vif(reg, type = "predictor")
I encounter the error:
GVIFs computed for predictors
Error in Math.data.frame(list(GVIF = c(1.26950310090809, 1.39338672776922, :
non-numeric-alike variable(s) in data frame: Interacts With, Other Predictors
I don’t know what’s causing this. Any ideas?
It looks like the computation within vif is obstructed for some reason, but I have no idea why.
EDIT-Solved: Sorry, I realized my mistake now. I actually ran the following code and then got that error.
round(vif(reg, type = "predictor"),2)
The problem is vif(reg, type = “terms”) returns a vector as output, whereas vif(reg, type = “predictor”) returns a data.frame with non-numeric values in it.
Are you able to make this question reproducible? Sample data would be very useful, see stackoverflow.com/q/5963269 , minimal reproducible example, and stackoverflow.com/tags/r/info.
Nope. I see your point. I’ll try to do it sometime later.