choose_model_aic_single¶
- threadcount.fit.choose_model_aic_single(model_list, d_aic=-150)[source]¶
Determine best modelresult in a list, chosen by computing \({\Delta}aic\).
Note: we now look at aic_real, defined in
threadcount.lmfit_ext.aic_real()This function uses the aic (Akaike Information Criterion) to choose between several models fit to the same data. Our general philosophy: choose simpler models.
The default change in aic we consider significant (-150) is quite high compared to a standard -10 you may see in statistics, since we are intending to identify the model components with physical processes in the galaxy. This value was chosen by observing fits to several different spectra and choosing the desired number of gaussian components by eye, then finding a \({\Delta}aic\) which came close to accomplishing that. via wikipedia: The \(exp((AIC_{min} − AIC_i)/2)\) is known as the relative liklihood of model i.
The numbers returned begin with 1, not 0 as is usual in python. If no results in model_list are valid, then -1 will be returned.
The algorithm goes as follows:
Lets say model_list = [model1, model2] (note the numbers begin with 1).
If model2.aic_real - model1.aic_real < d_aic:
return 2
else:
return 1.
Lets now say model_list = [model1, model2, model3].
If model2.aic_real - model1.aic_real < d_aic:
This means that model2 is better. We will eliminate model1 as an option, then apply bullet point 1, with [model2, model3], returning whichever number is better (so the return value will be 2 or 3).
else:
This means that model2 is not better than model1. We will eliminate model2 as an option, then apply bullet point 1, using [model1, model3], returning either 1 or 3.
TODO: I think if we get a choice of 3 from this way, we should flag it for manual inspection, since it may only be slightly better than model2 and so our philosophy of less complex is better would be violated.
- Parameters:
model_list (list of
lmfit.model.ModelResult) – A list of different model results which have been fit to the same data. Right now, the length must be no longer than 3. The order of the models is assumed to be from least complex -> more complex.d_aic (float, optional) – The change in fit aic (Akaike Information Criterion) indicating a significantly better fit, by default -150.
- Returns:
The index+1 of the model chosen with this algorithm. Returns -1 if all models are invalid.
- Return type: