Skip to content

Instantly share code, notes, and snippets.

@behinger
Created January 28, 2019 10:08
Show Gist options
  • Save behinger/e4f1ec07a6ca3d25f6e172eb8c48e240 to your computer and use it in GitHub Desktop.
Save behinger/e4f1ec07a6ca3d25f6e172eb8c48e240 to your computer and use it in GitHub Desktop.
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