6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
18 my $cmd_line = $0 . " " . join( " ", @ARGV );
22 my %required_options = ( "thetas:s"=>'theta list',
23 "omegas:s"=>'omega list',
24 "sigmas:s"=>'sigma list' );
26 my %optional_options = ( "max_iterations:i" => '',
29 "ofv_increase:f" => '',
30 "significant_digits:i" => '',
31 "rse_thetas:s" => 'theta rel. SE list',
32 "rse_omegas:s" => 'omega rel. SE list',
33 "rse_sigmas:s" => 'sigma rel. SE list');
35 my $res = GetOptions( \%options,
36 @common_options::get_opt_strings,
37 keys(%required_options),
38 keys(%optional_options) );
45 $help_text{Pre_help_message} = <<'EOF';
46 <h3 class="heading1">llp</h3>
48 Perl script for log-likelihood profiling of NONMEM runs.
50 <h3 class="heading1">Usage:</h3>
53 $help_text{Description
} = <<'EOF';
54 <h3 class="heading1">Description:</h3>
56 The Log-likelihood Profiling tool can be used to assess
57 confidence interval limits for parameter estimates. The
58 -2*log-likelihood of hierarchical models are chi-square
59 distributed. Fixing a parameter reduces the number of parameters
60 of the model by one. To be able to say, for a given level of
61 confidence, that there is a higher likelihood that the data has
62 been produced by a system described by the full model than by one
63 described by the reduced, the difference in the -2*log-likelihood
64 should be at least X. For example, using a confidence level of
65 95%, the difference (or X above) should be at least 3.84. The
66 minimal number of arguments include a modelfile name and a
67 listing of parameters, given that an output file with standard
68 error estimates exist.
71 $help_text{Examples
} = <<'EOF';
72 <h3 class="heading1">Example:</h3>
74 <p class="style2">llp -model=run89.mod -thetas='1,2'</p>
76 This will make the llp tool try to estimate the confidence
77 intervals for thetas one and two of the model in run89.mod. It
78 will base the first guesses on the standard error estimates from
81 <p class="style2">llp -model=run89.mod -thetas='1,2' -rse_thetas='20,30'</p>
83 In this example, we explicitly specify the relative standard
84 errors which is necessary if we do not have an output file with
85 standard error estimates.
88 $help_text{Options
} = <<'EOF';
89 <h3 class="heading1">Options:</h3>
91 The options are given here in their long form. Any option may be
92 abbreviated to any nonconflicting prefix. The <span class="style2">-threads</span> option
93 may be abbreviated to <span class="style2">-t</span>(or even <span class="style2">-thr</span>) but <span class="style2">-debug</span> may not be
94 abbreviated to <span class="style2">-d</span> because it conflicts with <span class="style2">-debug_packages</span> and
95 <span class="style2">-debug_subroutines</span>.
97 The following options are valid:
100 $help_text{-h
} = <<'EOF';
101 <p class="style2">-h | -?</p>
103 With -h or -? llp will print a list of options and exit.
106 $help_text{-help
} = <<'EOF';
107 <p class="style2">-help</p>
109 With -help llp will print this, longer, help message.
112 $help_text{-model
} = <<'EOF';
113 <p class="style2">-model='filename'</p>
115 The name of the model file. May be specified with or without the
119 $help_text{-outputfile
} = <<'EOF';
120 <p class="style2">-outputfile='filename'</p>
122 The name of the NONMEM output file. The default value is the
123 name of the model file with a '.mod' substituted with
124 '.lst'. Example: if the modelfile is run89.mod, the default name
125 of the output file is run89.lst. If the name of the modelfile is
126 cmd123 the default name of the output file is cmd123.lst. If the
127 name of your output file does not follow this standard, you have
128 to specify it with this option.
131 $help_text{-thetas
} = <<'EOF';
132 <p class="style2">-thetas, -omegas, -sigmas='comma-separated list of parameter
135 Specifies the parameters for which the llp should try to assess
136 confidence intervals.
139 $help_text{-rse_thetas
} = <<'EOF';
140 <p class="style2">-rse_thetas, -rse_omegas, -rse_sigmas='comma-separated list of
141 relative standard errors'</p>
143 The relative standard errors should be specified in percent (%).
146 $help_text{-max_iterations
} = <<'EOF';
147 <p class="style2">-max_iterations=integer</p>
149 This number limits the number of search iterations for each
150 interval limit. If the llp has not found the upper limit for a
151 parameter after max_iteration number of guesses it
152 terminates. The default value is 10.
155 $help_text{-significant_digits
} = <<'EOF';
156 <p class="style2">-significant_digits=integer</p>
158 Specifies the number of significant digits that is required for
159 the test of the increase in objective function value.
162 $help_text{-normq
} = <<'EOF';
163 <p class="style2">-normq=number</p>
165 This number is used for calculating the first guess of the
166 confidence interval limits. If the standard errors exist, the
169 <p class="style2">maximum-likelihood estimate ± normq * standard error</p>
171 otherwise it will be approximated with
173 <p class="style2">maximum-likelihood estimate ± normq * rse_parameter/100 * maximum-likelihood estimate</p>
175 where rse_parameter is rse_thetas, rse_omegas or rse_sigmas. The
176 default value is 1.96 which translates a 95% confidence interval
177 assuming normal distribution of the parameter estimates.
180 $help_text{-ofv_increase
} = <<'EOF';
181 <p class="style2">-ofv_increase</p>
183 The increase in objective function value associated with the
184 desired confidence interval. The default value is 3.84.
187 $help_text{Post_help_message
} = <<'EOF';
188 Also see 'execute -help' for a description of common options.
191 common_options
::online_help
( 'llp', \
%options, \
%help_text, \
%required_options, \
%optional_options);
193 ## Check that we do have a model file
194 if ( scalar(@ARGV) < 1 ) {
195 print "At least on model file must be specified. Use 'llp -h' for help.\n";
199 if( scalar(@ARGV) > 1 ){
200 print "LLP can only handle one modelfile. Use 'llp -h' for help.\n";
204 unless( $options{'thetas'} or $options{'omegas'} or $options{'sigmas'}){
205 print "You must specify one of the '--thetas', '--omegas' or '--sigmas' options\n";
209 ui
-> category
( 'llp' );
210 ui
-> silent
(1) if( $options{'silent'} );
212 debug
-> level
( $options{'debug'} );
213 debug
-> package( $options{'debug_package'} );
214 debug
-> subroutine
( $options{'debug_subroutine'} );
215 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
217 my @thetas = split( ',',$options{'thetas'} );
218 my @omegas = split( ',',$options{'omegas'} );
219 my @sigmas = split( ',',$options{'sigmas'} );
220 my @rse_thetas = split( ',',$options{'rse_thetas'} );
221 my @rse_omegas = split( ',',$options{'rse_omegas'} );
222 my @rse_sigmas = split( ',',$options{'rse_sigmas'} );
224 my ( %checked_rse_thetas, %checked_rse_omegas, %checked_rse_sigmas );
226 foreach my $param ( 'thetas', 'omegas', 'sigmas' ) {
227 my $nse = eval('$#rse_'.$param)+1;
229 my $npa = eval('$#'.$param)+1;
230 die "The number of $param ($npa) does not match the number of relative standard errors ($nse)\n"
231 if ( not $npa == $nse );
232 for ( my $i = 0; $i < $npa; $i++ ) {
233 eval( '$checked_rse_'.$param.'{$'.$param.'['.$i.']} = $rse_'.$param."[$i]" ),"\n";
238 my $eval_string = common_options
::model_parameters
(\
%options);
240 my $model = model
-> new
( eval( $eval_string ),
241 filename
=> $ARGV[0],
242 debug
=> $options{'debug'},
243 ignore_missing_output_files
=> 1);
245 ## Create new Llp object:
246 my $llp = tool
::llp
->
247 new
( eval( $common_options::parameters
),
248 max_iterations
=> $options{'max_iterations'},
249 models
=> [ $model ],
250 normq
=> $options{'normq'},
251 ofv_increase
=> $options{'ofv_increase'},
252 significant_digits
=> $options{'significant_digits'},
253 run_thetas
=> \
@thetas,
254 run_omegas
=> \
@omegas,
255 run_sigmas
=> \
@sigmas,
256 rse_thetas
=> \
%checked_rse_thetas,
257 rse_omegas
=> \
%checked_rse_omegas,
258 rse_sigmas
=> \
%checked_rse_sigmas );
260 open(CMD
, ">", $llp -> directory
. "/command.txt");
261 print CMD
$cmd_line, "\n";
265 $llp -> print_results
;