Author: bugman
Date: Thu Feb 5 19:26:32 2015
New Revision: 27569
URL: http://svn.gna.org/viewcvs/relax?rev=27569&view=rev
Log:
Implementation of the statistics.aic user function.
This is very similar to the statistics.model user function - the code was
copied and only slightly
modified. The new user function will calculate the current chi-squared value
per model, obtain the
model statistics, calculate the AIC value per model, and store the AIC value,
chi-squared value and
number of parameters in the appropriate location for the model in the relax
data store.
Modified:
trunk/pipe_control/statistics.py
trunk/user_functions/statistics.py
Modified: trunk/pipe_control/statistics.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/statistics.py?rev=27569&r1=27568&r2=27569&view=diff
==============================================================================
--- trunk/pipe_control/statistics.py (original)
+++ trunk/pipe_control/statistics.py Thu Feb 5 19:26:32 2015
@@ -31,6 +31,48 @@
from specific_analyses.api import return_api
+def aic():
+ """Calculate and store Akaike's Information Criterion (AIC) for each
model."""
+
+ # Checks.
+ check_pipe()
+
+ # The specific analysis API object.
+ api = return_api()
+
+ # Calculate the chi2.
+ print("Calculating the chi-squared value for the current parameter
values.")
+ api.calculate()
+
+ # Loop over the base models.
+ print("\nStoring the model statistics.")
+ for model_info in api.model_loop():
+ # Title printout.
+ api.print_model_title(model_info=model_info)
+
+ # Get the model statistics.
+ k, n, chi2 = api.model_statistics(model_info=model_info)
+
+ # Calculate the AIC value.
+ aic = chi2 + 2.0*k
+
+ # The model container.
+ container = api.get_model_container(model_info=model_info)
+
+ # Store the statistics.
+ container.chi2 = chi2
+ container.num_params = k
+ container.aic = aic
+
+ # Statistics printout.
+ data = [
+ ["Chi-squared value:", "%20f" % chi2],
+ ["Number of parameters (k):", "%20i" % k],
+ ["Akaike's Information Criterion (AIC):", "%20f" % aic]
+ ]
+ write_data(out=sys.stdout, data=data)
+
+
def model_statistics():
"""Calculate and store the model statistics."""
Modified: trunk/user_functions/statistics.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/user_functions/statistics.py?rev=27569&r1=27568&r2=27569&view=diff
==============================================================================
--- trunk/user_functions/statistics.py (original)
+++ trunk/user_functions/statistics.py Thu Feb 5 19:26:32 2015
@@ -24,7 +24,7 @@
# relax module imports.
from graphics import WIZARD_IMAGE_PATH
-from pipe_control.statistics import model_statistics
+from pipe_control.statistics import aic, model_statistics
from user_functions.data import Uf_info; uf_info = Uf_info()
from user_functions.objects import Desc_container
@@ -34,6 +34,21 @@
uf_class.title = "Class containing the statistics related functions."
uf_class.menu_text = "&statistics"
uf_class.gui_icon = "oxygen.actions.office-chart-pie"
+
+
+# The statistics.aic user function.
+uf = uf_info.add_uf('statistics.aic')
+uf.title = "Calculate and store Akaike's Information Criterion (AIC) for each
model."
+uf.title_short = "Calculate AIC values."
+# Description.
+uf.desc.append(Desc_container())
+uf.desc[-1].add_paragraph("This will perform a calculation to obtain the
chi-squared statistic for the current parameter values for each model, count
the number of parameters per model and calculate Akaike's Information Criterion
(AIC) using the formula AIC = chi2 + 2k. The AIC values, chi-squared values,
and number of parameters will be stored in the appropriate location for the
model in the relax data store.")
+uf.backend = aic
+uf.menu_text = "&aic"
+uf.gui_icon = "relax.discrepancy_curve"
+uf.wizard_apply_button = False
+uf.wizard_size = (700, 400)
+uf.wizard_image = WIZARD_IMAGE_PATH + 'statistics.png'
# The statistics.model user function.
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits