Skip to content

Commit

Permalink
VIF (#26)
Browse files Browse the repository at this point in the history
* VIF and GVIF
  • Loading branch information
palday authored Sep 6, 2023
1 parent 64d7d28 commit 20b38e1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StatsAPI"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
authors = ["Milan Bouchet-Valat <[email protected]"]
version = "1.6.0"
version = "1.7.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
47 changes: 47 additions & 0 deletions src/regressionmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,50 @@ function linearpredictor end
In-place version of [`linearpredictor`](@ref), storing the result in `storage`.
"""
function linearpredictor! end

"""
vif(m::RegressionModel)
Compute the variance inflation factor (VIF).
The [VIF](https://en.wikipedia.org/wiki/Variance_inflation_factor) measures
the increase in the variance of a parameter's estimate in a model with multiple parameters relative to
the variance of a parameter's estimate in a model containing only that parameter.
See also [`gvif`](@ref).
!!! warning
This method will fail if there is (numerically) perfect multicollinearity,
i.e. rank deficiency. In that case though, the VIF
is not particularly informative anyway.
"""
function vif end
# This generic function is owned by StatsModels.jl, which is the sole provider
# of the default definition.

"""
gvif(m::RegressionModel; scale=false)
Compute the generalized variance inflation factor (GVIF).
If `scale=true`, then each GVIF is scaled by the degrees of freedom
for (number of coefficients associated with) the predictor: ``GVIF^(1 / (2*df))``.
The [GVIF](https://doi.org/10.2307/2290467)
measures the increase in the variance of a (group of) parameter's estimate in a model
with multiple parameters relative to the variance of a parameter's estimate in a
model containing only that parameter. For continuous, numerical predictors, the GVIF
is the same as the VIF, but for categorical predictors, the GVIF provides a single
number for the entire group of contrast-coded coefficients associated with a categorical
predictor.
See also [`vif`](@ref).
## References
Fox, J., & Monette, G. (1992). Generalized Collinearity Diagnostics.
Journal of the American Statistical Association, 87(417), 178. doi:10.2307/2290467
"""
function gvif end
# This generic function is owned by StatsModels.jl, which is the sole provider
# of the default definition.

2 comments on commit 20b38e1

@palday
Copy link
Member Author

@palday palday commented on 20b38e1 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/90936

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.7.0 -m "<description of version>" 20b38e1f73d70fe528097f2f23d662e8830e14ad
git push origin v1.7.0

Please sign in to comment.