macroeco.compare.AIC¶
- macroeco.compare.AIC(data, model, params=None, corrected=True)¶
Akaike Information Criteria given data and a model
Parameters: data : iterable
Data for analysis
model : obj
Scipy frozen distribution object. When freezing, keyword args loc and scale should only be included if they represent a parameter.
params : int
Number of parameters in the model. If None, calculated from model object.
corrected : bool
If True, calculates the small-sample size correct AICC. Default True.
Returns: float :
AIC(C) value
Notes
AICC should be used when the number of observations is < 40.
References
[1] Burnham, K and Anderson, D. (2002) Model Selection and Multimodel Inference: A Practical and Information-Theoretic Approach (p. 66). New York City, USA: Springer. Examples
>>> import macroeco.models as md >>> import macroeco.compare as comp
>>> # 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 >>> comp.AIC(rand_samp, md.nbinom_ztrunc(*mle_nbd)) 765.51518598676421
>>> # Get AIC for logser >>> comp.AIC(rand_samp, md.logser(*mle_logser)) 777.05165086534805
>>> # Support for for zero-truncated NBD over logseries because AIC is >>> # smaller
>>> # Call AIC with params given as 2 (should be the same as above) >>> comp.AIC(rand_samp, md.nbinom_ztrunc(*mle_nbd), params=2) 765.51518598676421
>>> # Call AIC without sample size correction >>> comp.AIC(rand_samp, md.nbinom_ztrunc(*mle_nbd), params=2, corrected=False) 765.39147464655798