0
$\begingroup$

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

enter image description here

enter image description here

$\endgroup$
5
  • 5
    $\begingroup$ 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? $\endgroup$ – gung - Reinstate Monica Nov 8 '14 at 17:35
  • $\begingroup$ 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. $\endgroup$ – user785099 Nov 8 '14 at 18:08
  • $\begingroup$ 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? $\endgroup$ – user785099 Nov 8 '14 at 18:09
  • 3
    $\begingroup$ 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. $\endgroup$ – gung - Reinstate Monica Nov 8 '14 at 18:15
  • $\begingroup$ Gung, are there any specific pre-processing steps for handing factor (categorical variables" when having both them and continuous variables? Thanks. $\endgroup$ – user785099 Nov 8 '14 at 20:40
4
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$ – Pedram Feb 26 '19 at 17:43
  • $\begingroup$ 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! $\endgroup$ – Björn Backgård Mar 2 '19 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.