Skip to content

Commit

Permalink
updates on arLRT and arWaterfallPlot
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-rachel committed Jan 31, 2024
1 parent e9dbb68 commit 8ee14b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 15 additions & 1 deletion arFramework3/MatlabTools/arLRT.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
% [pval,q] = arLRT(DeltaChi2, DeltaDF, alpha)
%
% Performs Likelihood Ratio Test
%
% DeltaDF degrees of freedom
% alpha significance level
%
% q = TRUE: accept H0, the smaller model can not be dismissed
% q = FALSE: reject H0, dismiss smaller model in favour of larger model
%
% Example: (ar2 ist the larger model, m1 must be nested in m2, i.e. a special case)
% ar = ar1;
% arCalcMerit
% [~,m1] = arGetMerit;
% ar = ar2;
% arCalcMerit
% [~,m2] = arGetMerit;
% DeltaChi2 = m1.loglik_all - m2.loglik_all % must be positive
% DeltaDF = m2.npara - m1.npara; % must be positive


function [pval,q] = arLRT(DeltaChi2, DeltaDF, alpha)
if(~exist('alpha','var') || isempty(alpha))
alpha = 0.05;
end
pval = 1-chi2cdf(DeltaChi2, DeltaDF);
q = pval > alpha;
8 changes: 4 additions & 4 deletions arFramework3/arWaterfallPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
%
% see also arPlotChi2s

function arWaterfallPlot
function [fig, axis] = arWaterfallPlot
global ar

fig = figure();
if(min(ar.chi2s)>0)
semilogy(1:length(ar.chi2s),sort(ar.chi2s),'.','MarkerSize',12)
axis = semilogy(1:length(ar.chi2s),sort(ar.chi2s),'.','MarkerSize',12);
else
plot(1:length(ar.chi2s),sort(ar.chi2s),'.','MarkerSize',12)
axis = plot(1:length(ar.chi2s),sort(ar.chi2s),'.','MarkerSize',12);
end
xlabel('Fit index [sorted]')
ylabel('Merit after optimization')
xlim([0,length(ar.chi2s)+1])
title(['Waterfall plot: ',num2str(length(ar.chi2s)),' fits, ',num2str(sum(isinf(ar.chi2s))), ' failed'])
grid on

0 comments on commit 8ee14b7

Please sign in to comment.