mailr9696 - /1.3/generic_fns/model_selection.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by sebastien . morin . 1 on October 09, 2009 - 14:44:
Author: semor
Date: Fri Oct  9 14:44:40 2009
New Revision: 9696

URL: http://svn.gna.org/viewcvs/relax?rev=9696&view=rev
Log:
Improved the error handling for AICc model selection.

The code now tells users with too small datasets (n<=k) why AICc model 
selection does not work in
their situation.

This follows a discussion started at:
https://mail.gna.org/public/relax-devel/2009-10/msg00015.html
(# Message-id: <4ACD6F60.7060102@xxxxxxxxx>)


Modified:
    1.3/generic_fns/model_selection.py

Modified: 1.3/generic_fns/model_selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/model_selection.py?rev=9696&r1=9695&r2=9696&view=diff
==============================================================================
--- 1.3/generic_fns/model_selection.py (original)
+++ 1.3/generic_fns/model_selection.py Fri Oct  9 14:44:40 2009
@@ -73,7 +73,12 @@
     @rtype:         float
     """
 
-    return chi2 + 2.0*k + 2.0*k*(k + 1.0) / (n - k - 1.0)
+    if n > (k+1):
+        return chi2 + 2.0*k + 2.0*k*(k + 1.0) / (n - k - 1.0)
+    elif n == (k+1):
+        raise RelaxError("The size of the dataset, n=%s, is too small for 
this model of size k=%s.  This situation causes a fatal division by zero 
as:\n    AICc = chi2 + 2k + 2k*(k + 1) / (n - k - 1).\n\nPlease use AIC model 
selection instead." % (n, k))
+    elif n < (k+1):
+        raise RelaxError("The size of the dataset, n=%s, is too small for 
this model of size k=%s.  This situation produces a negative, and hence 
nonsense, AICc score as:\n    AICc = chi2 + 2k + 2k*(k + 1) / (n - k - 
1).\n\nPlease use AIC model selection instead." % (n, k))
 
 
 def bic(chi2, k, n):




Related Messages


Powered by MHonArc, Updated Fri Oct 09 16:00:02 2009