-
Notifications
You must be signed in to change notification settings - Fork 1
/
vif.ridge.Rd
134 lines (109 loc) · 4.3 KB
/
vif.ridge.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/vif.ridge.R
\name{vif.ridge}
\alias{vif.ridge}
\alias{print.vif.ridge}
\alias{plot.vif.ridge}
\title{Variance Inflation Factors for Ridge Regression}
\usage{
\method{vif}{ridge}(mod, ...)
\method{print}{vif.ridge}(x, digits = max(4, getOption("digits") - 5), ...)
\method{plot}{vif.ridge}(
x,
X = c("lambda", "df"),
col = c("black", "red", "darkgreen", "blue", "darkcyan", "magenta", "brown",
"darkgray"),
pch = c(15:18, 7, 9, 12, 13),
xlab,
ylab = "Variance Inflation",
xlim,
ylim,
...
)
}
\arguments{
\item{mod}{A \code{"ridge"} object computed by \code{\link{ridge}}}
\item{\dots}{Other arguments passed to methods}
\item{x}{A \code{ridge} object, as fit by \code{\link{ridge}}}
\item{digits}{Number of digits to display in the \code{print} method}
\item{X}{What to plot as the horizontal coordinate, one of \code{c("lambda", "df")}}
\item{col}{A numeric or character vector giving the colors used to plot the
ridge trace curves. Recycled as necessary.}
\item{pch}{Vector of plotting characters used to plot the ridge trace
curves. Recycled as necessary.}
\item{xlab}{Label for horizontal axis}
\item{ylab}{Label for vertical axis}
\item{xlim, ylim}{x, y limits for the plot. You may need to adjust these to allow for the variable labels.}
}
\value{
\code{vif} returns a \code{"vif.ridge"} object, which is a list of four components
\item{vif}{a data frame of the same size and
shape as \code{coef{mod}}. The columns correspond to the predictors in the
model and the rows correspond to the values of \code{lambda} in ridge
estimation.}
\item{lambda}{the vector of ridge constants from the original call to \code{\link{ridge}} }
\item{df}{the vector of effective degrees of freedom corresponding to \code{lambda}}
\item{criteria}{the optimal values of \code{lambda}}
}
\description{
The function \code{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 \eqn{\lambda} parameter.
Variance inflation factors are calculated using the simplified formulation
in Fox & Monette (1992).
The \code{plot.vif.ridge} method plots variance inflation factors for a \code{"vif.ridge"} object
in a similar style to what is provided by \code{\link{traceplot}}. That is, it plots the VIF for each
coefficient in the model against either the ridge \eqn{\lambda} tuning constant or it's equivalent
effective degrees of freedom.
}
\examples{
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
# plot VIFs
pch <- c(15:18, 7, 9)
clr <- c("black", rainbow(5, start=.6, end=.1))
### Transition examples, because the vif() method now returns a list structure
### rather than a data.frame
vr <- vridge$vif
matplot(rownames(vr), vr, type='b',
xlab='Ridge constant (k)', ylab="Variance Inflation",
xlim=c(0, 0.08),
col=clr, pch=pch, cex=1.2)
text(0.0, vr[1,], colnames(vr), pos=4)
# matplot(lridge$df, vridge, type='b',
# xlab='Degrees of freedom', ylab="Variance Inflation",
# col=clr, pch=pch, cex=1.2)
# text(6, vridge[1,], colnames(vridge), pos=2)
# more useful to plot VIF on the sqrt scale
# matplot(rownames(vridge), sqrt(vridge), type='b',
# xlab='Ridge constant (k)', ylab=expression(sqrt(VIF)),
# xlim=c(-0.01, 0.08),
# col=clr, pch=pch, cex=1.2, cex.lab=1.25)
# text(-0.01, sqrt(vridge[1,]), colnames(vridge), pos=4, cex=1.2)
# matplot(lridge$df, sqrt(vridge), type='b',
# xlab='Degrees of freedom', ylab=expression(sqrt(VIF)),
# col=clr, pch=pch, cex=1.2, cex.lab=1.25)
# text(6, sqrt(vridge[1,]), colnames(vridge), pos=2, cex=1.2)
}
\references{
Fox, J. and Monette, G. (1992). Generalized collinearity
diagnostics. \emph{JASA}, \bold{87}, 178-183, \doi{10.1080/01621459.1992.10475190}.
}
\seealso{
\code{\link[car]{vif}}, \code{\link{precision}}
}
\author{
Michael Friendly
}
\keyword{models}
\keyword{regression}