Home > Matching_SYM_LSM > src > Functions > Statistics > check_estimation_result.m

check_estimation_result

PURPOSE ^

% check estimation result, PCV Sect. 4.6.8

SYNOPSIS ^

function P=check_estimation_result(R, x_true, C0, s0q_sample, x_sample, S, text)

DESCRIPTION ^

% check estimation result, PCV Sect. 4.6.8

 check_estimation_result(R,x_true,S0,s0q_sample,x_sample,S,text)

 R          = redundancy (d.o.f. of variance factor)
 x_true     = Ux1 vector of parameters
 C0         = UxU reference covariance matrix of estimated parameters
 s0q_sample = Kx1 vector of variance factors
 x_sampl    = KxU matrix of estimated parameters
 S          = significance level of tests
 text       = string characterizing problem

 P's        = position in range of confidence intervall mapped to [-1,+1]

 provides three tests
 - variance factor (if not only ones, eg for algebraic estimation)
 - covariance matrix
 - bias

 Wolfgang Förstner 2016-09-28
 wfoerstn@uni-bonn.de

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% check estimation result, PCV Sect. 4.6.8
0002 %
0003 % check_estimation_result(R,x_true,S0,s0q_sample,x_sample,S,text)
0004 %
0005 % R          = redundancy (d.o.f. of variance factor)
0006 % x_true     = Ux1 vector of parameters
0007 % C0         = UxU reference covariance matrix of estimated parameters
0008 % s0q_sample = Kx1 vector of variance factors
0009 % x_sampl    = KxU matrix of estimated parameters
0010 % S          = significance level of tests
0011 % text       = string characterizing problem
0012 %
0013 % P's        = position in range of confidence intervall mapped to [-1,+1]
0014 %
0015 % provides three tests
0016 % - variance factor (if not only ones, eg for algebraic estimation)
0017 % - covariance matrix
0018 % - bias
0019 %
0020 % Wolfgang Förstner 2016-09-28
0021 % wfoerstn@uni-bonn.de
0022 
0023 function P=check_estimation_result(R, x_true, C0, s0q_sample, x_sample, S, text)
0024 
0025 % number of parameters
0026 U = length(x_true);
0027 % sample size
0028 K = size(x_sample,1);
0029 
0030 disp('++++++++++++++++++++++++++++++++++++++++++++++++')
0031 disp(strcat('Checks for ', text))
0032 disp(['Number U of unknown parameters = ', num2str(U)]);
0033 disp(['Redundancy R                   = ', num2str(R)]);
0034 disp(['Number K of samples            = ', num2str(K)]);
0035 disp('-------------------------------------------------')
0036 
0037 %% mean and covariance matrix of sample
0038 me = mean(x_sample);
0039 dx = me'-x_true;
0040 Ce = cov(x_sample);
0041 
0042 %% check of sigma_0 (two-sided), PCV (4.354) ff
0043 P_sigma=0;
0044 if sum(s0q_sample) ~= 0
0045     mean_s02 = mean(s0q_sample);
0046     F_tol_o = finv(1 - (1 - S) / 2, K * R, 100000000);
0047     F_tol_u = finv((1 - S) / 2, K * R, 100000000);
0048     
0049     if mean_s02 > F_tol_u && mean_s02 < F_tol_o
0050         disp(['variance factor s_0^2      ok: F(mean(s_0^2)) = ', ...
0051             num2str(mean_s02, '% 12.4f'), '     in [', ...
0052             num2str(F_tol_u, '% 12.4f'), ',', num2str(F_tol_o, '% 12.4f'), ']']);
0053     else
0054         disp(['variance factor  s_0^2 not ok: F(mean(s_0^2)) = ', ...
0055             num2str(mean_s02, '% 12.4f'), ' not in [', ...
0056             num2str(F_tol_u, '% 12.4f'), ',', num2str(F_tol_o, '% 12.4f'), '] *****']);
0057     end
0058     % plot histogram of variance factors with expected density (F-distibution)
0059     screensize = plot_init;
0060     f = figure('Color', 'w', 'Position', [20 20 screensize / 2]);
0061     hold on
0062     % number of bins = sqrt(K)
0063     N_bin = ceil(sqrt(K));
0064     % plot histogram
0065     hist(s0q_sample, N_bin);
0066     % store bin-centres r
0067     [~, r] = hist(s0q_sample, N_bin);
0068     % determine scale
0069     range = abs(r(N_bin) - r(1)) * N_bin / (N_bin - 1);
0070     % plot density with correct scale
0071     plot(r, N_bin * range * chi2pdf(r*R, R)*R, '-r', 'LineWidth', 2);
0072     title(['Histogram of ', num2str(K), ' variance factors with reference density (', text, ')']);
0073 a=[F_tol_u,F_tol_o];
0074  b=mean_s02;
0075  P_sigma=2*((log(b)-(log(a(1))+log(a(2)))/2)/(log(a(2))-log(a(1))));
0076  end
0077  
0078 %% Check of covariance matrix (two-sided), PCV (4.356) ff
0079 % Koch Parametersch Schätzung und Hypothesentests in linearen Modellen,
0080 % 2004, (287.5)
0081 %Ce,C0,K,S
0082 [lambda, T,~] = check_CovM(Ce, C0, K, S);
0083 
0084 if lambda > T(1) && lambda < T(2)
0085     disp(['covariance matrix C_xx     ok: X(CovM)        = ', ...
0086         num2str(lambda, '% 12.4f'), '     in [', num2str(T(1), '% 12.4f'), ...
0087         ',', num2str(T(2), '% 12.4f'), ']']);
0088 else
0089     disp(['covariance matrix C_xx not ok: X(CovM)        = ', ...
0090         num2str(lambda, '% 12.4f'), ' not in [', num2str(T(1), '% 12.4f'), ...
0091         ',', num2str(T(2), '% 12.4f'), '] *****']);
0092 end
0093 a=T;
0094 b=lambda;
0095 P_CovM=2*((log(b)-(log(a(1))+log(a(2)))/2)/(log(a(2))-log(a(1))));
0096 
0097 %% Check of mean parameters (two-sided), PCV (4.359) ff
0098 
0099 X_mean = K * dx' * inv(Ce) * dx;                                           %#ok<MINV>
0100 X_mean_tol_h = chi2inv(1 - (1 - S) / 2, U);
0101 X_mean_tol_l = chi2inv((1 - S) / 2, U);
0102 
0103 if X_mean < X_mean_tol_h && X_mean > X_mean_tol_l
0104     disp(['mean of parameters x       ok: X(mean(dx)))   = ', ...
0105         num2str(X_mean, '% 12.4f'), '     in [', ...
0106         num2str(X_mean_tol_l, '% 12.4f'), ',', num2str(X_mean_tol_h, '% 12.4f'), ']']);
0107 else
0108     disp(['mean of parameters x   not ok: X(mean(dx))   = ', ...
0109         num2str(X_mean, '% 12.4f'), ' not in [', ...
0110         num2str(X_mean_tol_l, '% 12.4f'), ',', num2str(X_mean_tol_h, '% 12.4f'), ']', ' *****']);
0111 end
0112 a=[X_mean_tol_l,X_mean_tol_h];
0113 b=X_mean;
0114 P_mean=2*((log(b)-(log(a(1))+log(a(2)))/2)/(log(a(2))-log(a(1))));
0115 
0116 P=[P_sigma,P_CovM,P_mean];

Generated on Sun 19-Jul-2020 23:00:25 by m2html © 2005