Skip to content

Commit 4bd4d68

Browse files
committed
Merge branch 'master' of https://github.com/ICB-DCM/PESTO
2 parents b5aea90 + 0a6e1a5 commit 4bd4d68

File tree

5 files changed

+43
-44
lines changed

5 files changed

+43
-44
lines changed

examples/conversion_reaction/mainConversionReaction.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@
261261

262262
%% Confidence interval evaluation -- Parameters
263263
% Confidence intervals to the confidence levels fixed in the array
264-
% alpha
264+
% confLevels
265265
% are computed based on local approximations from the Hessian matrix at the
266266
% optimum, based on the profile likelihoods and on the parameter sampling.
267267

268-
alpha = [0.9,0.95,0.99];
269-
parameters = getParameterConfidenceIntervals(parameters, alpha, optionsPesto);
268+
confLevels = [0.9,0.95,0.99];
269+
parameters = getParameterConfidenceIntervals(parameters, confLevels, optionsPesto);
270270

271271

272272
%% Evaluation of properties for multi-start local optimization results -- Properties
@@ -298,7 +298,7 @@
298298
% properties in different fashion, based on local approximations, profile
299299
% likelihoods and samples.
300300

301-
properties = getPropertyConfidenceIntervals(properties, alpha, optionsProperties);
301+
properties = getPropertyConfidenceIntervals(properties, confLevels, optionsProperties);
302302

303303

304304
%% Comparison of calculated parameter profiles

examples/enzymatic_catalysis/mainEnzymaticCatalysis.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@
125125
% Confidence Intervals for the Parameters are inferred from the local
126126
% optimization and the sampling information.
127127

128-
% Set alpha levels
129-
alphaLevels = [0.8, 0.9, 0.95, 0.99];
128+
% Set confidence levels
129+
confLevels = [0.8, 0.9, 0.95, 0.99];
130130

131131
display(' Computing confidence intervals...');
132-
parameters = getParameterConfidenceIntervals(parameters, alphaLevels, optionsPesto);
132+
parameters = getParameterConfidenceIntervals(parameters, confLevels, optionsPesto);
133133

134134

135135
%% Perform Multistart optimization
@@ -166,7 +166,7 @@
166166
% Confidence Intervals for the Parameters are inferred from the local
167167
% optimization and the sampling information.
168168
display(' Computing confidence intervals...');
169-
parameters = getParameterConfidenceIntervals(parameters, alphaLevels, optionsPesto);
169+
parameters = getParameterConfidenceIntervals(parameters, confLevels, optionsPesto);
170170

171171

172172
%% Calculate Profile Likelihoods
@@ -209,4 +209,4 @@
209209
%% Calculate Confidence Intervals
210210
% Confidence Intervals for the Parameters are inferred from the local
211211
% optimization, the sampling and the profile information.
212-
parameters = getParameterConfidenceIntervals(parametersNew, alphaLevels, optionsPesto);
212+
parameters = getParameterConfidenceIntervals(parametersNew, confLevels, optionsPesto);

examples/mRNA_transfection/mainTransfection.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,21 +311,21 @@
311311

312312

313313
%% Confidence interval evaluation -- Parameters
314-
% Confidence intervals to the confidence levels fixed in the array alpha
314+
% Confidence intervals to the confidence levels fixed in the array confLevels
315315
% are computed based on local approximations from the Hessian matrix at the
316316
% optimum, based on the profile likelihoods and on the parameter sampling.
317317

318-
alpha = [0.9,0.95,0.99];
318+
confLevels = [0.9,0.95,0.99];
319319

320320
% Computation for the first mode
321321
optionsPesto.MAP_index = 1;
322322
optionsPesto.parameter_index = 1 : parameters.number;
323-
parameters = getParameterConfidenceIntervals(parameters, alpha, optionsPesto);
323+
parameters = getParameterConfidenceIntervals(parameters, confLevels, optionsPesto);
324324

325325
% Computation for the second mode
326326
optionsPesto.MAP_index = MAP_index2;
327327
optionsPesto.parameter_index = [3, 4];
328-
parametersAlt = getParameterConfidenceIntervals(parametersAlt, alpha, optionsPesto);
328+
parametersAlt = getParameterConfidenceIntervals(parametersAlt, confLevels, optionsPesto);
329329

330330
%% Evaluation of properties for multi-start local optimization results -- Properties
331331
% The values of the properties are evaluated at the end points of the
@@ -353,7 +353,7 @@
353353
% properties in different fashion, based on local approximations, profile
354354
% likelihoods and samples.
355355

356-
properties = getPropertyConfidenceIntervals(properties, alpha);
356+
properties = getPropertyConfidenceIntervals(properties, confLevels);
357357

358358
%% Comparison of calculated parameter profiles
359359

getConfidenceIntervals.m

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
function pStruct = getConfidenceIntervals(pStruct, alpha, type, varargin)
1+
function pStruct = getConfidenceIntervals(pStruct, confLevels, type, varargin)
22
% getConfidenceIntervals() calculates the confidence intervals for the
33
% model parameters or properties. This is done by four approaches:
44
% The values of CI.local_PL and CI.PL are determined by the point on which
5-
% a threshold according to the confidence level alpha (calculated by a
5+
% a threshold according to the confidence level (calculated by a
66
% chi2-distribution) is reached. local_PL computes this point by a local
77
% approximation around the MAP estimate using the Hessian matrix, PL uses
88
% the profile likelihoods instead.
99
% The value of CI.local_B is computed by using the cummulative distribution
1010
% function of a local approximation of the profile based on the Hessian
1111
% matrix at the MAP estimate.
1212
% The value of CI.S is calculated using samples for the model parameters
13-
% and the according percentiles based on the confidence levels alpha.
13+
% and the according percentiles based on the confidence levels.
1414
%
1515
% USAGE:
16-
% * pStruct = getConfidenceIntervals(pStruct, alpha)
16+
% * pStruct = getConfidenceIntervals(pStruct, confLevels)
1717
%
1818
% Parameters:
1919
% pStruct: parameter or properties struct
20-
% alpha: vector with desired confidence levels for the intervals
20+
% confLevels: vector with desired confidence levels for the intervals
2121
% varargin:
2222
% options: A PestoOptions instance
2323
%
@@ -64,32 +64,32 @@
6464
end
6565

6666
% Initialization
67-
pStruct.CI.alpha_levels = alpha;
67+
pStruct.CI.confLevels = confLevels;
6868

69-
% Loop: alpha levels
70-
for iConfLevel = 1:length(alpha)
69+
% Loop: confidence levels
70+
for iConfLevel = 1:length(confLevels)
7171
% Loop: Parameters
7272
for iP = options.(p_index)
7373
if isfield(pStruct,'MS')
74-
pStruct = getCIfromOptimization(pStruct, alpha(iConfLevel), type, iMAP, iP, iConfLevel, options);
74+
pStruct = getCIfromOptimization(pStruct, confLevels(iConfLevel), type, iMAP, iP, iConfLevel, options);
7575
end
7676

7777
% Confidence intervals computed using profile likelihood
7878
if isfield(pStruct,'P')
79-
pStruct = getCIfromProfiles(pStruct, alpha(iConfLevel), type, iMAP, iP, iConfLevel);
79+
pStruct = getCIfromProfiles(pStruct, confLevels(iConfLevel), type, iMAP, iP, iConfLevel);
8080
end
8181

8282
% Confidence intervals computed using sample
8383
if isfield(pStruct,'S')
84-
pStruct.CI.S(iP,:,iConfLevel) = prctile(pStruct.S.(type)(iP,:,1),50 + 100*[-alpha(iConfLevel)/2, alpha(iConfLevel)/2]);
84+
pStruct.CI.S(iP,:,iConfLevel) = prctile(pStruct.S.(type)(iP,:,1),50 + 100*[-confLevels(iConfLevel)/2, confLevels(iConfLevel)/2]);
8585
end
8686
end
8787
end
8888

8989
%% Output
9090
switch options.mode
9191
case 'visual'
92-
plotConfidenceIntervals(pStruct, alpha, [], options);
92+
plotConfidenceIntervals(pStruct, [], options);
9393
disp('-> Calculation of confidence intervals for parameters FINISHED.');
9494
case 'text'
9595
disp('-> Calculation of confidence intervals for parameters FINISHED.');
@@ -99,7 +99,7 @@
9999
end
100100

101101

102-
function pStruct = getCIfromOptimization(pStruct, alpha, type, iMAP, iP, iConfLevel, options)
102+
function pStruct = getCIfromOptimization(pStruct, confLevel, type, iMAP, iP, iConfLevel, options)
103103

104104
if strcmp(type, 'par')
105105
% Inversion of Hessian
@@ -116,36 +116,36 @@
116116

117117
% Confidence intervals computed using local approximation and a
118118
% threshold (-> similar to PL-based confidence intervals)
119-
pStruct.CI.local_PL(iP,1,iConfLevel) = pStruct.MS.(type)(iP,iMAP) - sqrt(icdf('chi2',alpha,1)*Sigma(iP,iP));
120-
pStruct.CI.local_PL(iP,2,iConfLevel) = pStruct.MS.(type)(iP,iMAP) + sqrt(icdf('chi2',alpha,1)*Sigma(iP,iP));
119+
pStruct.CI.local_PL(iP,1,iConfLevel) = pStruct.MS.(type)(iP,iMAP) - sqrt(icdf('chi2',confLevel,1)*Sigma(iP,iP));
120+
pStruct.CI.local_PL(iP,2,iConfLevel) = pStruct.MS.(type)(iP,iMAP) + sqrt(icdf('chi2',confLevel,1)*Sigma(iP,iP));
121121

122122
% Confidence intervals computed using local approximation and the
123123
% probability mass (-> similar to Bayesian confidence intervals)
124-
pStruct.CI.local_B(iP,1,iConfLevel) = icdf('norm', (1-alpha)/2,pStruct.MS.(type)(iP,iMAP),sqrt(Sigma(iP,iP)));
125-
pStruct.CI.local_B(iP,2,iConfLevel) = icdf('norm',1-(1-alpha)/2,pStruct.MS.(type)(iP,iMAP),sqrt(Sigma(iP,iP)));
124+
pStruct.CI.local_B(iP,1,iConfLevel) = icdf('norm', (1-confLevel)/2,pStruct.MS.(type)(iP,iMAP),sqrt(Sigma(iP,iP)));
125+
pStruct.CI.local_B(iP,2,iConfLevel) = icdf('norm',1-(1-confLevel)/2,pStruct.MS.(type)(iP,iMAP),sqrt(Sigma(iP,iP)));
126126

127127
end
128128

129129

130-
function pStruct = getCIfromProfiles(pStruct, alpha, type, iMAP, iP, iConfLevel)
130+
function pStruct = getCIfromProfiles(pStruct, confLevel, type, iMAP, iP, iConfLevel)
131131

132132
if ~isempty(pStruct.P(iP).(type))
133133
% left bound
134134
if strcmp(type, 'par')
135135
ind = find(pStruct.P(iP).(type)(iP,:) <= pStruct.MS.(type)(iP,iMAP));
136-
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',alpha,1)/2),1,'last');
136+
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',confLevel,1)/2),1,'last');
137137
if ~isempty(j)
138138
pStruct.CI.PL(iP,1,iConfLevel) = interp1(pStruct.P(iP).R(ind([j,j+1])),...
139-
pStruct.P(iP).(type)(iP,ind([j,j+1])),exp(-icdf('chi2',alpha,1)/2));
139+
pStruct.P(iP).(type)(iP,ind([j,j+1])),exp(-icdf('chi2',confLevel,1)/2));
140140
else
141141
pStruct.CI.PL(iP,1,iConfLevel) = -inf;
142142
end
143143
else
144144
ind = find(pStruct.P(iP).(type) <= pStruct.MS.(type)(iP,1));
145-
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',alpha,1)/2),1,'last');
145+
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',confLevel,1)/2),1,'last');
146146
if ~isempty(j)
147147
pStruct.CI.PL(iP,1,iConfLevel) = interp1(pStruct.P(iP).R(ind([j,j+1])),...
148-
pStruct.P(iP).(type)(ind([j,j+1])),exp(-icdf('chi2',alpha,1)/2));
148+
pStruct.P(iP).(type)(ind([j,j+1])),exp(-icdf('chi2',confLevel,1)/2));
149149
else
150150
pStruct.CI.PL(iP,1,iConfLevel) = -inf;
151151
end
@@ -154,19 +154,19 @@
154154
% right bound
155155
if strcmp(type, 'par')
156156
ind = find(pStruct.P(iP).(type)(iP,:) >= pStruct.MS.(type)(iP,iMAP));
157-
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',alpha,1)/2),1,'first');
157+
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',confLevel,1)/2),1,'first');
158158
if ~isempty(j)
159159
pStruct.CI.PL(iP,2,iConfLevel) = interp1(pStruct.P(iP).R(ind([j-1,j])),...
160-
pStruct.P(iP).(type)(iP,ind([j-1,j])),exp(-icdf('chi2',alpha,1)/2));
160+
pStruct.P(iP).(type)(iP,ind([j-1,j])),exp(-icdf('chi2',confLevel,1)/2));
161161
else
162162
pStruct.CI.PL(iP,2,iConfLevel) = inf;
163163
end
164164
else
165165
ind = find(pStruct.P(iP).(type) >= pStruct.MS.(type)(iP,1));
166-
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',alpha,1)/2),1,'first');
166+
j = find(pStruct.P(iP).R(ind) <= exp(-icdf('chi2',confLevel,1)/2),1,'first');
167167
if ~isempty(j)
168168
pStruct.CI.PL(iP,2,iConfLevel) = interp1(pStruct.P(iP).R(ind([j-1,j])),...
169-
pStruct.P(iP).(type)(ind([j-1,j])),exp(-icdf('chi2',alpha,1)/2));
169+
pStruct.P(iP).(type)(ind([j-1,j])),exp(-icdf('chi2',confLevel,1)/2));
170170
else
171171
pStruct.CI.PL(iP,2,iConfLevel) = inf;
172172
end

plotConfidenceIntervals.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function fh = plotConfidenceIntervals(pStruct, alpha, varargin)
1+
function fh = plotConfidenceIntervals(pStruct, varargin)
22
% plotConfidenceIntervals.m visualizes confidence itervals stored in either
33
% the parameters or properties struct .CI
44
%
@@ -30,7 +30,6 @@
3030
% information about parameters and results of optimization (.MS)
3131
% and uncertainty analysis (.P and .S). This structures is the output
3232
% of plotMultiStarts.m, getProfiles.m or plotSamples.m.
33-
% alpha: significance levels
3433
% varargin:
3534
% method: integer array, from which method confidence intervals
3635
% should be plotted:
@@ -298,8 +297,8 @@
298297
methodsOut.name{iMeth} = tempMethName{j};
299298
end
300299
end
301-
methodsOut.numLevels = length(pStruct.CI.alpha_levels);
302-
methodsOut.levels = pStruct.CI.alpha_levels;
300+
methodsOut.numLevels = length(pStruct.CI.confLevels);
301+
methodsOut.levels = pStruct.CI.confLevels;
303302
methodsOut.num = length(methodsOut.name);
304303
methodsOut.bars = linspace(0.3, 0.15, methodsOut.numLevels);
305304
colors = nan(methodsOut.num, 3, methodsOut.numLevels);

0 commit comments

Comments
 (0)