Learn R Programming

genridge (version 0.8.0)

vif.ridge: Variance Inflation Factors for Ridge Regression

Description

The function vif.ridge calculates variance inflation factors for the predictors in a set of ridge regression models indexed by the tuning/shrinkage factor, returning one row for each value of the \(\lambda\) parameter.

Variance inflation factors are calculated using the simplified formulation in Fox & Monette (1992).

The plot.vif.ridge method plots variance inflation factors for a "vif.ridge" object in a similar style to what is provided by traceplot. That is, it plots the VIF for each coefficient in the model against either the ridge \(\lambda\) tuning constant or it's equivalent effective degrees of freedom.

Usage

# S3 method for ridge
vif(mod, ...)

# S3 method for vif.ridge print(x, digits = max(4, getOption("digits") - 5), ...)

# S3 method for vif.ridge plot( x, X = c("lambda", "df"), Y = c("vif", "sqrt"), col = c("black", "red", "darkgreen", "blue", "darkcyan", "magenta", "brown", "darkgray"), pch = c(15:18, 7, 9, 12, 13), xlab, ylab, xlim, ylim, ... )

Value

vif returns a "vif.ridge" object, which is a list of four components

vif

a data frame of the same size and shape as coef{mod}. The columns correspond to the predictors in the model and the rows correspond to the values of lambda in ridge estimation.

lambda

the vector of ridge constants from the original call to ridge

df

the vector of effective degrees of freedom corresponding to lambda

criteria

the optimal values of lambda

Arguments

mod

A "ridge" object computed by ridge

...

Other arguments passed to methods

x

A ridge object, as fit by ridge

digits

Number of digits to display in the print method

X

What to plot as the horizontal coordinate, one of c("lambda", "df")

Y

What to plot as the vertical coordinate, one of c("vif", "sqrt"), where the latter plots \(\sqrt{VIF}\).

col

A numeric or character vector giving the colors used to plot the ridge trace curves. Recycled as necessary.

pch

Vector of plotting characters used to plot the ridge trace curves. Recycled as necessary.

xlab

Label for horizontal axis

ylab

Label for vertical axis

xlim, ylim

x, y limits for the plot. You may need to adjust these to allow for the variable labels.

Author

Michael Friendly

References

Fox, J. and Monette, G. (1992). Generalized collinearity diagnostics. JASA, 87, 178-183, tools:::Rd_expr_doi("10.1080/01621459.1992.10475190").

See Also

vif, precision

Examples

Run this code

data(longley)
lmod <- lm(Employed ~ GNP + Unemployed + Armed.Forces + Population + 
                      Year + GNP.deflator, data=longley)
vif(lmod)

lambda <- c(0, 0.005, 0.01, 0.02, 0.04, 0.08)
lridge <- ridge(Employed ~ GNP + Unemployed + Armed.Forces + 
                           Population + Year + GNP.deflator, 
		             data=longley, lambda=lambda)

coef(lridge)

# get VIFs for the shrunk estimates
vridge <- vif(lridge)
vridge
names(vridge)



# plot VIFs
pch <- c(15:18, 7, 9)
clr <- c("black", rainbow(5, start=.6, end=.1))

plot(vridge, 
     col=clr, pch=pch, cex = 1.2,
     xlim = c(-0.02, 0.08))

plot(vridge, X = "df",
     col=clr, pch=pch, cex = 1.2,
     xlim = c(4, 6.5))

# Better to plot sqrt(VIF). Plot against degrees of freedom
plot(vridge, X = "df", Y="sqrt",
     col=clr, pch=pch, cex = 1.2,
     xlim = c(4, 6.5))



Run the code above in your browser using DataLab