macroeco.compare.AIC_compare¶
- macroeco.compare.AIC_compare(aic_list)¶
Calculates delta AIC and AIC weights from a list of AIC values
Parameters: aic_list : iterable
AIC values from set of candidat models
Returns: tuple :
First element contains the delta AIC values, second element contains the relative AIC weights.
Notes
AIC weights can be interpreted as the probability that a given model is the best model in the set.
Examples
>>> # Generate random data >>> rand_samp = md.nbinom_ztrunc.rvs(20, 0.5, size=100)
>>> # Fit Zero-truncated NBD (Full model) >>> mle_nbd = md.nbinom_ztrunc.fit_mle(rand_samp)
>>> # Fit a logseries (limiting case of Zero-truncated NBD, reduced model) >>> mle_logser = md.logser.fit_mle(rand_samp)
>>> # Get AIC for ztrunc_nbinom >>> nbd_aic = comp.AIC(rand_samp, md.nbinom_ztrunc(*mle_nbd))
>>> # Get AIC for logser >>> logser_aic = comp.AIC(rand_samp, md.logser(*mle_logser))
>>> # Make AIC list and get weights >>> aic_list = [nbd_aic, logser_aic] >>> comp.AIC_compare(aic_list) (array([ 0. , 19.11806518]), array([ 9.99929444e-01, 7.05560486e-05]))
>>> # Zero-truncated NBD is a far superior model based on AIC weights