# Regarding analysis of regression result and vif result

I am working on building a regression model. There are 51 points. The number of predictor variables is 37. The following is the result of running lm result. When trying to detecting the multicollinearity issue, the vif also drops the error message. What are the problems of this model.

model1<-lm(test.1[,3] ~ as.matrix(test[,-c(1,2,3)]),data=test)
summary(model1)
vif(model1)
Error in vif.default(model1) : model contains fewer than 2 terms  • Your model is pretty saturated. You can't really use this many variables; you probably want to try something like the LASSO. What are the predictor variables? Are they factors? – gung - Reinstate Monica Nov 8 '14 at 17:35
• gung, thanks for your reply. Some predictor variables are continuous value, while some others are binary variable. When you refer to factors, what do you mean here? I should cast some variables into factors. Please explain more. Thanks. – user785099 Nov 8 '14 at 18:08
• the reason that I am doing vif is to find some correlated variables and remove them from the model. Should I do step-wise variable selection first? – user785099 Nov 8 '14 at 18:09
• No, you should not use step-wise selection, see my answer here: Algorithms for automatic model selection. Try also reading some threads categorized under model-selection & feature-selection. By "factor", I mean a categorical variable w/ multiple levels. – gung - Reinstate Monica Nov 8 '14 at 18:15
• Gung, are there any specific pre-processing steps for handing factor (categorical variables" when having both them and continuous variables? Thanks. – user785099 Nov 8 '14 at 20:40

## 1 Answer

A little late maybe, but I found this question while having the same problem myself.

The vif-function in CAR (which you seem to be using) only works when you specify a formula like

model1 <- lm(dependent ~ predictor1 + predictor2 + predictor3, data = df)


I suspect it uses the \$call in the regression object somehow.

• Do you mean that instead of using "model1", we should put a formula as a parameter for vif? If yes, I did it but still it does not work for me. – Pedram Feb 26 '19 at 17:43
• No what I meant was that you have to specify a formula, not use vectors and matrices directly, for the function to work. You supply the model object to the vif function, and it uses the formula to construct the matrices needed. You should use the lm function as I described above, then call vif with the lm object as argument: vif(model1) Try that! – Björn Backgård Mar 2 '19 at 9:30