vif.ridge | R Documentation |
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.
## S3 method for class 'ridge'
vif(mod, ...)
## S3 method for class 'vif.ridge'
print(x, digits = max(4, getOption("digits") - 5), ...)
## S3 method for class '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,
...
)
mod |
A |
... |
Other arguments passed to methods |
x |
A |
digits |
Number of digits to display in the |
X |
What to plot as the horizontal coordinate, one of |
Y |
What to plot as the vertical coordinate, one of |
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. |
vif
returns a "vif.ridge"
object, which is a list of four components
vif |
a data frame of the same size and
shape as |
lambda |
the vector of ridge constants from the original call to |
df |
the vector of effective degrees of freedom corresponding to |
criteria |
the optimal values of |
Michael Friendly
Fox, J. and Monette, G. (1992). Generalized collinearity diagnostics. JASA, 87, 178-183, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1992.10475190")}.
vif
, precision
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.