3 % ---------- Parameters for the plots ----------
5 rows = 3; % Number of rows in each figure
6 columns = 2; % Number of columns
7 polynomial = 3; % Degree of polynomial for
9 prediction_steps = 100; % The number of prediction
10 % steps in the plotted interval
11 extrapolate = 0.1; % Extrapolate this much
12 % outside the available
14 text_offset = 0.2; % The text below each graph
15 % will be placed this far
18 % ---------- Autogenerated code below ----------
22 col_names = [ sprintf(str_format,'par1');
23 sprintf(str_format,'par2');
24 sprintf(str_format,'par3');
25 sprintf(str_format,'par4');
26 sprintf(str_format,'par5');
27 sprintf(str_format,'par6');
28 sprintf(str_format,'par7');
29 sprintf(str_format,'par8');
30 sprintf(str_format,'par9');
31 sprintf(str_format,'par10');
32 sprintf(str_format,'par11');
33 sprintf(str_format,'par12');
34 sprintf(str_format,'par13')];
38 filename = 'llp_rr.csv';
40 % ---------- End autogenerated code ----------
42 % The rest of the code does not change between runs
44 profiling_log = load(filename);
46 [a, b] = size( profiling_log );
48 orig_est = profiling_log(1,1:2:b);
49 orig_low = profiling_log(2,1:2:b);
50 orig_upp = profiling_log(3,1:2:b);
52 [junk, n_par] = size( orig_est );
54 delta_ofv = profiling_log(:,2:2:b);
55 fixed_values = profiling_log(:,1:2:b);
56 fixed_lower = profiling_log(2:2:a,1:2:b);
57 fixed_upper = profiling_log(3:2:a,1:2:b);
58 log_fixed_values = log( fixed_values );
61 % Loop over all parameters, creating plots
65 % Plot and subplot handling
70 if row == (rows+1) || i == 1
77 if min(fixed_values(:,i)) <= 0 & max(fixed_values(:,i)) >= 0
78 X = fixed_values(:,i);
80 X = log_fixed_values(:,i);
82 x_nolog = fixed_values(:,i);
84 idx = isnan(X) | isnan(Y); % remove NaN's
86 x_nolog = x_nolog(~idx);
90 P = polyfit( X, Y, polynomial);
92 % Prepare the prediction
93 x_max = max( x_nolog );
94 x_min = min( x_nolog );
95 extra = ( x_max - x_min ) * extrapolate;
96 X_pred_max = x_max + extra;
97 X_pred_min = x_min - extra;
98 X_pred = X_pred_min:(X_pred_max-X_pred_min)/prediction_steps:X_pred_max;
101 if min(fixed_values(:,i)) <= 0 & max(fixed_values(:,i)) >= 0
102 pred_Y = polyval( P, X_pred );
104 pred_Y = polyval( P, log(X_pred) );
108 nplot = col+(row-1)*columns;
109 subplot(rows, columns, nplot);
111 % Plot the gathered profile
112 plot( x_nolog, Y, 'o' );
115 % Plot the predicted profile
116 plot( X_pred, pred_Y );
119 % Add line for maximum likelihood estimate
120 h = line( [orig_est(i), orig_est(i)], ax(3:4) );
122 % Add lines for the lower and upper confidence limits based on
123 % the standard errors
124 h = line( [orig_low(i), orig_low(i)], ax(3:4) );
125 set(h, 'LineStyle', '--' );
126 h = line( [orig_upp(i), orig_upp(i)], ax(3:4) );
127 set(h, 'LineStyle', '--' );
129 % Add lines for the lower and upper confidence limits as the are
130 % determined by the log-likelihood profiling tool
131 lower = fixed_lower(:,i);
132 idx = isnan( lower );
134 lower = lower(length(lower));
135 h = line( [lower, lower], ax(3:4) );
136 upper = fixed_upper(:,i);
137 idx = isnan( upper );
139 upper = upper(length(upper));
140 h =line([upper, upper], ax(3:4));
142 % Add a reference line for the ofv increase
143 h = line( ax(1:2),[goal, goal]);
145 % ----------- Add some text and figures ----------
147 % Maximum likelihood estimate
148 y_text = ax(3) - (ax(4)-ax(3))*text_offset;
149 text( orig_est(i), y_text, num2str(orig_est(i)) );
151 % upper SE confidence limit
152 y_text = ax(3) - (ax(4)-ax(3))*text_offset*2/3;
153 text( orig_upp(i), y_text, num2str(orig_upp(i)) );
155 % lower SE confidence limit
156 text( orig_low(i), y_text, num2str(orig_low(i)) );
158 % Upper likelihood-profiling confidence limit
159 y_text = ax(3) - (ax(4)-ax(3))*text_offset;
160 text( upper, y_text, num2str(upper) );
162 % Lower likelihood-profiling confidence limit
163 text( lower, y_text, num2str(lower) );
167 % Add title to each graph
168 title( col_names( i, : ) );