[R] vif() from Design and car

Frank E Harrell Jr feh3k at spamcop.net
Tue Oct 7 02:55:29 CEST 2003


On Mon, 06 Oct 2003 18:42:04 -0400
John Fox <jfox at mcmaster.ca> wrote:

> Dear Rajarshi,
> 
> I don't have the book to which Frank Harrell refers in the documentation 
> for the vif function in the Design package, but looking at the code for the 
> function, I believe that there's an error:
> 
> vif <-
> function (fit)
> {
>      v <- Varcov(fit, regcoef.only = TRUE)
>      nam <- dimnames(v)[[1]]
>      ns <- num.intercepts(fit)
> #    v <- solve(v)
>      if (ns > 0) {
>          v <- v[-(1:ns), -(1:ns), drop = FALSE]
>          nam <- nam[-(1:ns)]
>      }
>      d <- diag(v)^0.5
>      v <- diag(solve(v/(d %o% d)))
>      names(v) <- nam
>      v
> }
> 
> If you remove the line that I've commented-out, the function will, I 
> believe, return the usual results.

Thanks for the correction John and for pointing out the problem Rajarshi.  I'll put the correction in the next release.

Frank

> 
> I imagine that Frank can comment on this more definitively.
> 
> I hope that this helps,
>   John
> 
> At 05:07 PM 10/6/2003 -0400, Rajarshi Guha wrote:
> >Hi,
> >   I've been generating linear models with lm(). I wanted to look at the
> >VIF's for the coefficient. Using the vif() function from the package
> >Design, I would get unusually high VIF's.
> >
> >However using vif() from the car package I get more reasonable values
> >(ie in line with the quality of the model).
> >
> >What is the difference between the two vif functions? (I dont have
> >access to the reference in the Design's vif() help page)
> >
> >Thanks,
> >
> >-------------------------------------------------------------------
> >Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
> 
> -----------------------------------------------------
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada L8S 4M4
> email: jfox at mcmaster.ca
> phone: 905-525-9140x23604
> web: www.socsci.mcmaster.ca/jfox
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help


---
Frank E Harrell Jr    Professor and Chair            School of Medicine
                      Department of Biostatistics    Vanderbilt University




More information about the R-help mailing list