diff --git a/src/StatsBase.jl b/src/StatsBase.jl index 2d2344497..2d4e2ca36 100644 --- a/src/StatsBase.jl +++ b/src/StatsBase.jl @@ -205,6 +205,8 @@ export residuals, r2, r², + vif, + viftable, ConvergenceException, diff --git a/src/statmodels.jl b/src/statmodels.jl index 0e2b4af20..9c7412d8e 100644 --- a/src/statmodels.jl +++ b/src/statmodels.jl @@ -423,6 +423,29 @@ Return all parameters of a model. params(model) = error("params is not defined for $(typeof(model))") function params! end +""" + vif(model, param) + +Return the variance inflation factor for a parameter in a model. + +The [variance inflation factor (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 in of a paremeter's estimate in a model containing only that parameter. +""" +vif(model::StatisticalModel, param) = + error("vif(model::StatisticalModel, param) is not defined for $(typeof(model)).") + + +""" + viftable(model) + +Return the variance inflation factor for all parameters in a model as a `CoefTable`. + +See also [`vif`](@ref) +""" +viftable(model::StatisticalModel) = + error("viftable(model::StatisticalModel) is not defined for $(typeof(model)).") + ## coefficient tables with specialized show method mutable struct CoefTable diff --git a/test/statmodels.jl b/test/statmodels.jl index da8824cf3..cb50529e3 100644 --- a/test/statmodels.jl +++ b/test/statmodels.jl @@ -131,3 +131,6 @@ end err = @test_throws ArgumentError ConvergenceException(10,.1,.2) @test err.value.msg == "Change must be greater than tol." + +@test_throws MethodError vif() +@test_throws MethodError viftable()