Several goodness-of-fit (GoF) model indexes for Excel
Author: Christopher Teh Boon Sung, Uni. Putra Malaysia
Contact: christeh@yahoo.com; www.christopherteh.com
Initial Release: June 6, 2019
Updated: Oct. 25, 2021
MIT -licensed:
- Free to use, copy, share, and modify
- Give credit to the developer somewhere in your software code or documentation
List of GoF indexes (and the names of their functions in brackets):
- Mean Absolute Error (
fit_mae) - Normalized Mean Absolute Error (
fit_nmae) - Mean Bias Error (P-O) (
fit_mbe) - Mean Absolute Percentage Error (MAPE) (
fit_mape) - Mean Bias Percentage Error (MBPE) (
fit_mbpe) - Normalized Mean Bias Error (P-O) (
fit_nmbe) - Median Absolute Percentage Error (MAPE) (
fit_mdape) - Root Mean Square Error (
fit_rmse) - Original Index of Agreement (
fit_d) - New (Refined) Index of Agreement (
fit_dr) - RMSE to Standard Deviation Ratio (
fit_rsr) - Nash-Sutcliffe Efficiency (
fit_nse) - Normalized mean square error (
fit_nmse) - Fractional bias (
fit_fb) - Coefficient of Efficiency (
fit_coe) - Revised Mielke Index (
fit_mielke) - Persistence Index (
fit_pi) - Akaike Information Criterion (AIC) (
fit_aic) - Bayesian Information Criterion (BIC) (
fit_bic) - Theil's U2 Coefficient of Inequality (UII) (
fit_theilu2) - Kling-Gupta Efficiency (KGE) (
fit_kge)
Note:
- All indexes will ignore cells that are blank (empty), hidden, or contain
#N/Aerror - Missing values in cells should be left blank or use the function
NA()to indicate an error value in that cell
Installation:
- Open the Visual Basic Editor in Excel (via the Developer tab)
- Insert this file (
Gof.bas) as one of the modules in your workbook (see: https://youtu.be/ett0WiTfQuI).
Usage:
- All GoF functions start with
fit_<<name>>where<<name>>is the abbreviated name of the GoF index. For instance, the mean bias error (MBE) index function isfit_mbe, and the normalized mean absolute error (NMAE) function isfit_nmae. See the GoF module for the other functions. - To use the MBE function, type in
=fit_mbe(A1:A10, B1:B10), whereA1:A10is the range of cells containing the observed (measured) values andB1::B10the estimated (predicted) values. Other GoF functions are used in the same way, except for AIC and BIC functions. - To use the AIC function, type in
=fit_aic(A1:A10, B1:B10, 3, True)whereA1:A10andB1:B10contain the observed and estimated values, respectively; the third argument (value3) is the number of model parameters plus one (e.g., simple linear regression equation y = mx + c has 3 model parameters: m, c, and plus one); and the last parameter is True (by default) for second-order AIC. Set to False for first order AIC (use for large samples). - The BIC function is used in the same way as the AIC function, except the BIC function is
fit_bicand it has no fourth parameter, e.g.,=fit_bic(A1:A10, B1:B10, 3).