Created
January 28, 2019 10:08
-
-
Save behinger/e4f1ec07a6ca3d25f6e172eb8c48e240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vif = VIF(X) | |
[n, k] = size(X); | |
Exxprim = full(X'*X)/n; %I'm shocked if this isn't full so let's drop sparse now | |
Ex = full(mean(X))'; %same deal | |
COVX = (Exxprim - Ex*Ex'); | |
STDEVX = sqrt(diag(COVX)); | |
CORRX = COVX ./ (STDEVX * STDEVX'); | |
invcorrx = inv(CORRX); | |
vif = diag(invcorrx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment