% test CovM [lambda,T,F] = check_CovM(C_empir,C_theor,m,S) C_empir = empirical covariance matrix C_theor = theoretical covariance matrix m = sample size for determining empirical CovM S = significance level (close to 1) lambda = test statistic T = chi^2 threshold [high,low] F = refined F threshold [high,low] Wolfgang Förstner 2/2012 wfoerstn@uni-bonn.de
0001 %% test CovM 0002 % 0003 % [lambda,T,F] = check_CovM(C_empir,C_theor,m,S) 0004 % 0005 % C_empir = empirical covariance matrix 0006 % C_theor = theoretical covariance matrix 0007 % m = sample size for determining empirical CovM 0008 % S = significance level (close to 1) 0009 % 0010 % lambda = test statistic 0011 % T = chi^2 threshold [high,low] 0012 % F = refined F threshold [high,low] 0013 % 0014 % Wolfgang Förstner 2/2012 0015 % wfoerstn@uni-bonn.de 0016 0017 function [lambda, T, F] = sugr_check_CovM(C_empir, C_theor, m, S) 0018 0019 p = size(C_empir, 1); 0020 0021 lambda = m * (log(det(C_theor) / det(C_empir)) - p + trace(C_empir * inv(C_theor))); 0022 0023 Tup = chi2inv(S, 0.5 * p * (p + 1)); 0024 Tlow = chi2inv(1 - S, 0.5 * p * (p + 1)); 0025 T = [Tup, Tlow]; 0026 0027 D1 = (2 * p + 1 - 2 / (p + 1)) / (6 * m); 0028 D2 = (p - 1) * (p + 2) / (6 * m ^ 2); 0029 q1 = p * (p + 1) / 2; 0030 q2 = (q1 + 2) / (D2 - D1 ^ 2); 0031 b = q1 / (1 - D1 - q1 / q2); 0032 q2 = min(100000, q2); 0033 Fup = b * finv(S, q1, q2); 0034 Flow = b * finv(1 - S, q1, q2); 0035 F = [Fup, Flow]; 0036 0037 0038