Skip to content

Commit 20b38e1

Browse files
authored
VIF (#26)
* VIF and GVIF
1 parent 64d7d28 commit 20b38e1

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StatsAPI"
22
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
33
authors = ["Milan Bouchet-Valat <[email protected]"]
4-
version = "1.6.0"
4+
version = "1.7.0"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/regressionmodel.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,50 @@ function linearpredictor end
132132
In-place version of [`linearpredictor`](@ref), storing the result in `storage`.
133133
"""
134134
function linearpredictor! end
135+
136+
"""
137+
vif(m::RegressionModel)
138+
139+
Compute the variance inflation factor (VIF).
140+
141+
The [VIF](https://en.wikipedia.org/wiki/Variance_inflation_factor) measures
142+
the increase in the variance of a parameter's estimate in a model with multiple parameters relative to
143+
the variance of a parameter's estimate in a model containing only that parameter.
144+
145+
See also [`gvif`](@ref).
146+
147+
!!! warning
148+
This method will fail if there is (numerically) perfect multicollinearity,
149+
i.e. rank deficiency. In that case though, the VIF
150+
is not particularly informative anyway.
151+
"""
152+
function vif end
153+
# This generic function is owned by StatsModels.jl, which is the sole provider
154+
# of the default definition.
155+
156+
"""
157+
gvif(m::RegressionModel; scale=false)
158+
159+
Compute the generalized variance inflation factor (GVIF).
160+
161+
If `scale=true`, then each GVIF is scaled by the degrees of freedom
162+
for (number of coefficients associated with) the predictor: ``GVIF^(1 / (2*df))``.
163+
164+
The [GVIF](https://doi.org/10.2307/2290467)
165+
measures the increase in the variance of a (group of) parameter's estimate in a model
166+
with multiple parameters relative to the variance of a parameter's estimate in a
167+
model containing only that parameter. For continuous, numerical predictors, the GVIF
168+
is the same as the VIF, but for categorical predictors, the GVIF provides a single
169+
number for the entire group of contrast-coded coefficients associated with a categorical
170+
predictor.
171+
172+
See also [`vif`](@ref).
173+
174+
## References
175+
176+
Fox, J., & Monette, G. (1992). Generalized Collinearity Diagnostics.
177+
Journal of the American Statistical Association, 87(417), 178. doi:10.2307/2290467
178+
"""
179+
function gvif end
180+
# This generic function is owned by StatsModels.jl, which is the sole provider
181+
# of the default definition.

0 commit comments

Comments
 (0)