7 # Don't edit the line below, it must look exactly like this.
8 # Everything above this line will be replaced #
23 my $cmd_line = $0 . " " . join( " ", @ARGV );
27 my %optional_options = ( "predict_data:s" => undef,
28 "predict_model:s" => undef );
30 my $res = GetOptions( \%options,
31 @common_options::get_opt_strings,
32 keys(%optional_options) );
36 common_options::set_globals( \%options );
37 common_options::get_defaults( \%options, 'execute' );
38 common_options::online_help('execute', \%options, undef,{},{});
40 debug -> level( $options{'debug'} );
41 debug -> package( $options{'debug_package'} );
42 debug -> subroutine( $options{'debug_subroutine'} );
43 debug -> warn_with_trace( $options{'warn_with_trace'} );
47 if( $options{'outputfile'} ){
48 @outputfiles = split( /,/, $options{'outputfile'} );
51 if ( scalar( @ARGV ) < 1 ) {
52 unless( $options{'summarize'} and $options{'outputfile'} and not $options{'force'} ){
53 print "At least one model file must be specified. Use 'execute -h' for help.\n";
60 ui -> category( 'modelfit' );
62 random_set_seed_from_phrase( $options{'seed'} ) if ( defined $options{'seed'} );
66 my $eval_string = common_options::model_parameters(\%options);
68 foreach my $model_name ( @ARGV ){
69 my $outputfile = shift @outputfiles;
72 $model = model -> new ( eval( $eval_string ),
73 outputfile => $outputfile,
74 filename => $model_name,
75 ignore_missing_output_files => 1 );
77 if( $options{'nonparametric_etas'} or
78 $options{'nonparametric_marginals'} ) {
79 $model -> add_nonparametric_code;
82 if( $options{'shrinkage'} ) {
83 $model -> shrinkage_stats( enabled => 1 );
86 unless( -e $outputfile ){
87 print "The output file: $outputfile doesn't exist.\n";
90 $model = model -> new( eval( $eval_string ),
91 outputfile => $outputfile,
92 filename => 'dummy.mod',
93 ignore_missing_files => 1 );
96 push( @{$models_array}, $model );
100 if ( defined $options{'predict_data'} and defined $options{'predict_model'} ) {
101 if( scalar @{$models_array} > 1 ) {
102 debug -> die( message => "When using predict_data and predict_model, no "
103 ."more than one model at a time may be run with execute" );
105 my $outfile = $options{'predict_model'};
106 $outfile =~ s/\.mod//;
107 $outfile = $outfile.'.lst';
108 my $pred_mod = $models_array -> [0] -> copy( filename => $options{'predict_model'},
111 $pred_mod -> datafiles( new_names => [$options{'predict_data'}] );
112 $pred_mod -> ignore_missing_files(1);
113 $pred_mod -> outputfile( $outfile );
114 $pred_mod -> maxeval( new_values => [[0]] );
115 $pred_mod -> remove_records( type => 'covariance' );
116 $pred_mod -> update_inits( from_model => $models_array -> [0] );
118 foreach my $file ( @{$pred_mod -> table_names -> [0]} ) {
119 push( @new_tables, $options{'predict_model'}.'.'.$file );
121 $pred_mod -> table_names( new_names => [\@new_tables] );
122 $modelfit = tool::modelfit ->
123 new ( eval( $common_options::parameters ),
124 models => [$pred_mod] );
126 $modelfit = tool::modelfit ->
127 new ( eval( $common_options::parameters ),
128 models => $models_array );
131 open(CMD, ">", $modelfit -> directory . "/command.txt");
132 print CMD $cmd_line, "\n";
137 if( $options{'summarize'} ){
138 $modelfit -> summarize;