Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use StatsModels.[g]vif #22

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
version: [1.6, 1]
version: [1.8, 1]
arch: [x64]
os: [ubuntu-20.04] # macos-10.15, windows-2019
steps:
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MixedModelsExtras"
uuid = "781a26e1-49f4-409a-8f4c-c3159d78c17e"
authors = ["Phillip Alday <[email protected]> and contributors"]
version = "1.1.0"
version = "2.0.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -12,11 +12,11 @@ StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
MixedModels = "3, 4"
MixedModels = "4"
StatsBase = "0.33, 0.34"
StatsModels = "0.6.28, 0.7"
StatsModels = "0.7.3"
Tables = "1"
julia = "1.6"
julia = "1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
8 changes: 5 additions & 3 deletions src/MixedModelsExtras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ using StatsBase
using StatsModels
using Tables

using StatsModels: termnames, vif, gvif
export termnames, gvif, vif

StatsModels.termnames(::RandomEffectsTerm) = String[]

include("icc.jl")
export icc

include("r2.jl")
export r², r2, adjr², adjr2

include("vif.jl")
export termnames, gvif, vif

include("remef.jl")
export partial_fitted

Expand Down
143 changes: 0 additions & 143 deletions src/vif.jl

This file was deleted.

6 changes: 3 additions & 3 deletions test/vif.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ progress = false
fm2 = fit(MixedModel, @formula(reaction ~ 1 + days * days^2 + (1 | subj)),
dataset(:sleepstudy); progress)

ae_int = ArgumentError("VIF only defined for models with an intercept term")
ae_int = ArgumentError("VIF is only defined for models with an intercept term")
ae_nterm = ArgumentError("VIF not meaningful for models with only one non-intercept term")
@test_throws ae_int vif(fm0)
@test_throws ae_nterm vif(fm1)
Expand Down Expand Up @@ -46,15 +46,15 @@ end
duncan = rdataset("car", "Duncan")

lm1 = lm(@formula(Prestige ~ 1 + Income + Education), duncan)
@test termnames(lm1) == coefnames(lm1)
@test termnames(lm1)[2] == coefnames(lm1)
vif_lm1 = vif(lm1)

# values here taken from car
@test isapprox(vif_lm1, [2.1049, 2.1049]; atol=1e-5)
@test isapprox(vif_lm1, gvif(lm1))

lm2 = lm(@formula(Prestige ~ 1 + Income + Education + Type), duncan)
@test termnames(lm2) == ["(Intercept)", "Income", "Education", "Type"]
@test termnames(lm2)[2] == ["(Intercept)", "Income", "Education", "Type"]
@test isapprox(gvif(lm2), [2.209178, 5.297584, 5.098592]; atol=1e-5)
@test isapprox(gvif(lm2; scale=true),
[1.486330, 2.301648, 1.502666]; atol=1e-5)
Expand Down
Loading