Dear ?zg?r,
car::vif() produces a warning, not an error. It will proceed to compute VIFs
based on the correlation matrix of the coefficients (take a look at
car:::vif.lm) even if there is no intercept, and even though this would not
normally correspond to variance inflation due to correlation of the predictors.
If you think that makes sense, then by all means use the VIFs.
Best,
John
------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/
On Fri, 13 Apr 2012 09:49:54 -0700 (PDT)
?zg?r Asar <oasar at metu.edu.tr> wrote:> Dear all,
>
> I have faced a problem while calculating VIF values via the packages, car
> and HH for the models witout intercepts. Below is an illustrative example:
>
> 1) via the car package
>
> > y<-rnorm(100,0,1)
> > x1<-rnorm(100,0,1)
> > x2<-rnorm(100,0,1)
> > x3<-rnorm(100,0,1)
> > model1<-lm(y~-1+x1+x2+x3)
> > model2<-lm(y~-1+x1+x2)
> >library(car)
> > vif(model1)
> x1 x2 x3
> 1.000279 1.019231 1.019376
> Warning message:
> In vif.lm(model1) : No intercept: vifs may not be sensible.
> > vif(model2)
> x1 x2
> 1.000085 1.000085
> Warning message:
> In vif.lm(model2) : No intercept: vifs may not be sensible.
>
> 2) via the HH package
> > library(HH)
> > vif(model1)
> x2 x3
> 1.000557 1.000557
> > vif(model2)
> Error in vif.default(xx, na.action = na.action) :
> vif requires two or more X-variables.
>
> I could not understand why this occured. Does anyone have any idea about
it?
>
> Best
> Ozgur
>
>
>
>
> -----
>
> ************************************
> Ozgur ASAR
>
> Research Assistant
> Middle East Technical University
> Department of Statistics
> 06531, Ankara Turkey
> Ph: 90-312-2105309
> --
> View this message in context:
http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555402.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.