1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23   
 24  """Module containing the 'model_selection' user function class.""" 
 25  __docformat__ = 'plaintext' 
 26   
 27   
 28  from base_class import Basic_class 
 29  import arg_check 
 30  from generic_fns import model_selection 
 31   
 32   
 34      """Class containing the function for selecting which model selection method should be used.""" 
 35   
 37          """Function for model selection. 
 38   
 39          Keyword arguments 
 40          ~~~~~~~~~~~~~~~~~ 
 41   
 42          method:  The model selection technique (see below). 
 43   
 44          modsel_pipe:  The name of the new data pipe which will be created by this user function by 
 45              the copying of the selected data pipe. 
 46   
 47          pipes:  An array containing the names of all data pipes to include in model selection. 
 48   
 49   
 50          Description 
 51          ~~~~~~~~~~~ 
 52   
 53          The following model selection methods are supported: 
 54   
 55              AIC:  Akaike's Information Criteria. 
 56   
 57              AICc:  Small sample size corrected AIC. 
 58   
 59              BIC:  Bayesian or Schwarz Information Criteria. 
 60   
 61              Bootstrap:  Bootstrap model selection. 
 62   
 63              CV:  Single-item-out cross-validation. 
 64   
 65              Expect:  The expected overall discrepancy (the true values of the parameters are 
 66                       required). 
 67   
 68              Farrow:  Old model-free method by Farrow et al., 1994. 
 69   
 70              Palmer:  Old model-free method by Mandel et al., 1995. 
 71   
 72              Overall:  The realised overall discrepancy (the true values of the parameters are 
 73                        required). 
 74   
 75          For the methods 'Bootstrap', 'Expect', and 'Overall', the function 'monte_carlo' should have 
 76          previously been executed with the type argument set to the appropriate value to modify its 
 77          behaviour. 
 78   
 79          If the pipes argument is not supplied then all data pipes will be used for model selection. 
 80   
 81   
 82          Example 
 83          ~~~~~~~ 
 84   
 85          For model-free analysis, if the preset models 1 to 5 are minimised and loaded into the 
 86          program, the following commands will carry out AIC model selection and to place the selected 
 87          results into the 'mixed' data pipe, type one of: 
 88   
 89          relax> model_selection('AIC', 'mixed') 
 90          relax> model_selection(method='AIC', modsel_pipe='mixed') 
 91          relax> model_selection('AIC', 'mixed', ['m1', 'm2', 'm3', 'm4', 'm5']) 
 92          relax> model_selection(method='AIC', modsel_pipe='mixed', pipes=['m1', 'm2', 'm3', 'm4', 'm5']) 
 93          """ 
 94   
 95           
 96          if self._exec_info.intro: 
 97              text = self._exec_info.ps3 + "model_selection(" 
 98              text = text + "method=" + repr(method) 
 99              text = text + ", modsel_pipe=" + repr(modsel_pipe) 
100              text = text + ", pipes=" + repr(pipes) + ")" 
101              print(text) 
102   
103           
104          arg_check.is_str(method, 'model selection method') 
105          arg_check.is_str(modsel_pipe, 'model selection data pipe name') 
106          arg_check.is_str_list(pipes, 'data pipes', can_be_none=True, list_of_lists=True) 
107   
108           
109          model_selection.select(method=method, modsel_pipe=modsel_pipe, pipes=pipes) 
  110