Skip to content

Instantly share code, notes, and snippets.

@teaualune
Created September 29, 2013 17:10
Show Gist options
  • Save teaualune/6754408 to your computer and use it in GitHub Desktop.
Save teaualune/6754408 to your computer and use it in GitHub Desktop.
X = [94.66 6.89 64.06 27.13 0.128356534 1770.99 10.96; ...
93.79 3.76 81.33 14.34 0.136729489 1509.71 25.79; ...
93.45 9.95 87.66 29.68 0.608227884 1425.85 45.61; ...
95.81 9.16 104.47 20.81 0.689591432 2285.79 22.86; ...
72.71 14.75 67.74 10.55 0.067760754 266.42 50.21; ...
94.11 11.92 74.25 14.17 0.172147321 1597.82 28.82; ...
81.19 4.14 84.28 15.67 0.085490275 431.63 28.65; ...
92.49 8.45 87.3 18.24 0.125981923 1232.12 44.27; ...
93.15 3.43 83.96 12.99 0.155595884 1360.22 37.87; ...
95.64 8.36 115.84 10.71 0.675068648 2195.31 24.09; ...
92.86 6.99 74.04 12.41 0.160378175 1300.30 33.9; ...
92.02 9.95 73.28 12.58 0.301398699 1153.73 37.85; ...
93.74 3.3 87.27 15.63 0.128095072 1497.96 29.4; ...
95.14 2.4 80.19 16.88 0.128728078 1956.35 17.73; ...
86.73 0.95 78.35 10.57 0.109901381 653.48 28.02];
Y = [6, 4, 5, 5, 3, 2, 3, 5, 2, 3, 2, 5, 4, 4, 1]';
[B dev stats] = mnrfit(X, Y, 'model', 'ordinal');
VIF = zeros(1,7);
for i = 1:7
yy = X(:, i);
xx = [X(:, [1:(i-1),(i+1):end]), ones(length(yy), 1)];
[beta, sig, resid] = mvregress(xx, yy);
SSresid = sum(resid .^ 2);
SStotal = var(yy) * (length(yy) - 1);
VIF(i) = SStotal / SSresid;
end
% VIF =
%
% 8.4537 3.8093 5.2331 1.5366 5.4801 14.2211 3.5350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment