{"id":717,"date":"2014-12-17T21:02:32","date_gmt":"2014-12-17T21:02:32","guid":{"rendered":"http:\/\/kourentzes.com\/forecasting\/?p=717"},"modified":"2014-12-18T10:35:02","modified_gmt":"2014-12-18T10:35:02","slug":"the-bias-coefficient-a-new-metric-for-forecast-bias","status":"publish","type":"post","link":"https:\/\/kourentzes.com\/forecasting\/2014\/12\/17\/the-bias-coefficient-a-new-metric-for-forecast-bias\/","title":{"rendered":"The Bias Coefficient: a new metric for forecast bias"},"content":{"rendered":"<p style=\"text-align: justify;\">In this post I introduce a new bias metric that has several desirable properties over traditional ones.<\/p>\n<p style=\"text-align: justify;\">When evaluating forecasting performance it is important to look at two elements: forecasting accuracy and bias. Although there has been substantial progress in the measurement of accuracy with various metrics being proposed, there has been rather limited progress in measuring bias. A typical metrics is the Mean Error (ME):<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=ME+%3D+n%5E%7B-1%7D%5Csum_%7Bj%3D1%7D%5En%7Be_j%7D%2C&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='ME = n^{-1}\\sum_{j=1}^n{e_j},' title='ME = n^{-1}\\sum_{j=1}^n{e_j},' class='latex' \/>\n<p style=\"text-align: justify;\">where <em>n<\/em> is the number of errors <em>e<sub>j<\/sub><\/em>. Although in principle this is a scale dependent metric, this limitation is overcome by scaling appropriately the raw errors. Nonetheless, the ME still suffers from a number of other limitations. First, the size of errors is lost. Large positive and negative errors are lost. Although the bias information is retained we cannot infer whether an observed bias is associated with large or small errors. Second, the size of bias is very difficult to interpret, as the ME does not have any natural upper or lower bounds. Variants of ME, such as the Mean Percentage Errors (MPE) have been proposed to provide an easier to communicate bias size, expressed as a percentage:<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=MPE+%3D+%5Cfrac%7B100%7D%7Bn%7D%5Csum_%7Bj%3D1%7D%5En%7B%5Cfrac%7Be_j%7D%7By_j%7D%7D%2C&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='MPE = \\frac{100}{n}\\sum_{j=1}^n{\\frac{e_j}{y_j}},' title='MPE = \\frac{100}{n}\\sum_{j=1}^n{\\frac{e_j}{y_j}},' class='latex' \/>\n<p style=\"text-align: justify;\">where <em>y<sub>j<\/sub><\/em> is the actual observation at time <em>j<\/em>. However, MPE is again unbounded and introduces additional complications. For example the MPE is not symmetric in terms of how negative and positive biases are measured. Consider the following: the forecast for a period is 90, while the observed demand is 100. The error, measured as the difference between actual and forecasted values will be 10 and the MPE = 10%. If on the other hand the forecast was 100 and the demand was 90 the error would be -10, but the MPE = -11.1%, even though the bias is actually of the same size.<\/p>\n<p style=\"text-align: justify;\">In this <a title=\"Measuring the behaviour of experts on demand forecasting: a complex task\" href=\"http:\/\/kourentzes.com\/forecasting\/2014\/12\/17\/measuring-the-behaviour-of-experts-on-demand-forecasting-a-complex-task\/\">working paper<\/a> we propose a new metric, the <strong>Root Error<\/strong>, attempting to overcome these limitations. Complex number analysis is not a common tool in forecasting; however it has certain advantages that we can take advantage of here. We calculate the Root Error (RE) for each period as:<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=z_j+%3D+%5Csqrt%7Be_j%7D+%3D+a+%2B+bi.&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='z_j = \\sqrt{e_j} = a + bi.' title='z_j = \\sqrt{e_j} = a + bi.' class='latex' \/>\n<p style=\"text-align: justify;\">Since errors can be negative <em>z<sub>j<\/sub><\/em> can be a real or imaginary number and <em>i<\/em> is the imaginary unit that satisfies the equation <em>i<sup>2<\/sup>=-1<\/em>. Value <em>a<\/em> is the real part and <em>b<\/em> is the imaginary part of the complex number. For positive errors:<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=a+%3D+%5Csqrt%7Be%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='a = \\sqrt{e}' title='a = \\sqrt{e}' class='latex' \/>\n<p>and <em>b=0<\/em>, while for negative <em>a=0<\/em> and<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=b%3D%5Csqrt%7B%7Ce%7C%7D.&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='b=\\sqrt{|e|}.' title='b=\\sqrt{|e|}.' class='latex' \/>\n<p>We can summarise the RE with the <strong>Sum Root Error<\/strong> (SRE) and <strong>Mean Root Error<\/strong> (MRE) to summarise across several errors:<\/p>\n<p><img src='https:\/\/s0.wp.com\/latex.php?latex=SRE+%3D+%5Csum_%7Bj%3D1%7D%5En%7B%5Csqrt%7Be_j%7D%7D+%3D+%5Csum_%7Bj%3D1%7D%5En%7Ba_j%7D+%2B+i%5Csum_%7Bj%3D1%7D%5En%7Bb_j%7D%2C+&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='SRE = \\sum_{j=1}^n{\\sqrt{e_j}} = \\sum_{j=1}^n{a_j} + i\\sum_{j=1}^n{b_j}, ' title='SRE = \\sum_{j=1}^n{\\sqrt{e_j}} = \\sum_{j=1}^n{a_j} + i\\sum_{j=1}^n{b_j}, ' class='latex' \/><br \/>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=MRE+%3D+%5Cfrac%7B1%7D%7Bn%7DSRE+%3D+%5Cfrac%7B1%7D%7Bn%7D%5Csum_%7Bj%3D1%7D%5En%7Ba_j%7D+%2B+%5Cfrac%7Bi%7D%7Bn%7D%5Csum_%7Bj%3D1%7D%5En%7Bb_j%7D.&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='MRE = \\frac{1}{n}SRE = \\frac{1}{n}\\sum_{j=1}^n{a_j} + \\frac{i}{n}\\sum_{j=1}^n{b_j}.' title='MRE = \\frac{1}{n}SRE = \\frac{1}{n}\\sum_{j=1}^n{a_j} + \\frac{i}{n}\\sum_{j=1}^n{b_j}.' class='latex' \/><\/p>\n<p style=\"text-align: justify;\">These metrics are relatively robust to outliers due to the square root involved in the calculation. Let us assume that we have three experts A, B and C. The following figure shows how ME and MRE summarise the bias and error information differently.<\/p>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig1_.png\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-725 size-full aligncenter\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig1_.png\" alt=\"rooterror.fig1\" width=\"262\" height=\"220\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig1_.png 462w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig1_-150x125.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig1_-300x251.png 300w\" sizes=\"(max-width: 262px) 100vw, 262px\" \/><\/a><br \/>\n<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig2_.png\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-724 size-full aligncenter\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig2_.png\" alt=\"rooterror.fig2\" width=\"300\" height=\"110\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig2_.png 530w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig2_-150x55.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig2_-300x110.png 300w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">If the negative and positive errors are equal, then <em>a<\/em> and <em>b<\/em> will be equal and MRE will be on the diagonal. If the positive errors are more, or the negative, then the line will be under or over the diagonal respectively. The size of the bias is represented by how distant the MRE of each expert is from the diagonal. Also note that the MRE retains the size of errors, clearly highlighting that expert B is more inaccurate, although less biased than expert C.<\/p>\n<p style=\"text-align: justify;\">Expressing the complex errors in their polar form allows us to achieve a more intuitive interpretation. Let us define <em>\u03b3<\/em> as the angle of MRE:<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=+%5Cgamma+%3D+arctan%28b%2Fa%29%2C+%5Ctext%7Bif+%7D+a+%3E+0%2C&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' \\gamma = arctan(b\/a), \\text{if } a &gt; 0,' title=' \\gamma = arctan(b\/a), \\text{if } a &gt; 0,' class='latex' \/>\n<p style=\"text-align: justify;\">where <em>arctan<\/em> is the inverse tangent and <em>\u03b3<\/em> is expressed in radians. If <em>a=0<\/em> and <em>b&gt;0<\/em> then <em>\u03b3 = \u03c0\/2<\/em>. If both <em>a, b = 0<\/em> then <em>\u03b3 = 0<\/em>. Notice that the magnitude of MRE does not relate to the bias. Following the previous description of unbiasedness, a forecast will be unbiased for <em>\u03b3 = \u03c0\/4<\/em>, while all forecast errors will have an angle <em>\u03b3<\/em> between 0 and <em>\u03c0\/2<\/em>. Instead of using <em>\u03b3<\/em> that is expressed radians, we can define the <strong>Bias Coefficient<\/strong>:<\/p>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=%5Ckappa+%3D+1+-+%7B4%5Cgamma%7D%2F%7B%5Cpi%7D.&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\kappa = 1 - {4\\gamma}\/{\\pi}.' title='\\kappa = 1 - {4\\gamma}\/{\\pi}.' class='latex' \/>\n<p style=\"text-align: justify;\">The bias coefficient is a unit-free metric. A forecast that is always over the observed values will have a bias coefficient equal to -1, always over-forecasting, while the bias coefficient will be equal to 1 for the opposite case. Let us visualise the bias coefficient in the following figure. Assuming a large number of forecasts for different time series, the MRE per time series is calculated and subsequently the bias coefficient. This is then visualiased using a boxplot. The dot in the boxplot denotes the mean MRE.<\/p>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_.png\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-733 size-full aligncenter\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_.png\" alt=\"rooterror.fig3\" width=\"500\" height=\"155\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_.png 1139w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_-150x46.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_-300x92.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_-1024x316.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2014\/12\/rooterror.fig3_-660x203.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">The bias coefficient:<\/p>\n<ul style=\"text-align: justify;\">\n<li>is bounded, therefore we can characterise biases as strong or weak and have -1 and 1 as bounds of maximally biased forecasts.<\/li>\n<li>can be read similarly to the well known linear correlation coefficient. A zero value means no bias, while other values mean strong or weak bias, positive or negative. This makes it very easy to interpret and gives a non-relative understanding whether a forecast exhibits strong bias or not.<\/li>\n<li>is free of units or scale, allowing comparisons and summaries between different time series without any pre-processing.<\/li>\n<li>being unit free and bounded makes it ideal to benchmark the bias behaviour of different forecasts, methods, experts, organisations, sectors, etc.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">The Root Error has several interesting properties as a metric. The bias coefficient is only one of the ways to use this new metric to characterise the performance of forecasts. This <a title=\"Measuring the behaviour of experts on demand forecasting: a complex task\" href=\"http:\/\/kourentzes.com\/forecasting\/2014\/12\/17\/measuring-the-behaviour-of-experts-on-demand-forecasting-a-complex-task\/\">working paper<\/a> introduces the Root Error and discusses many of the properties and uses of the new metric. I believe you will find it interesting.<\/p>\n<p>I have updated <a title=\"TStools for R\" href=\"http:\/\/kourentzes.com\/forecasting\/2014\/04\/19\/tstools-for-r\/\">TStools<\/a> to include three new functions: <em>mre<\/em>, <em>mre.plot<\/em> and <em>bias.coeff<\/em> to help you experiment with the new metric and visualisations in the paper.<\/p>\n<p style=\"text-align: justify;\">Here is a quick demonstration of how to use these functions. Let us first create some random errors:<\/p>\n<pre>&gt; err &lt;- runif(10,-10,10)<\/pre>\n<p style=\"text-align: justify;\">Now let us calculate the Mean Root Error of these:<\/p>\n<pre>&gt; library(TStools)\r\n&gt; re &lt;- mre(err)\r\n&gt; re\r\n[1] 0.754675+1.924278i<\/pre>\n<p style=\"text-align: justify;\">Now let us calculate the bias coefficient for this:<\/p>\n<pre>&gt; bias.coeff(re)\r\n[1] -0.5241242<\/pre>\n<p style=\"text-align: justify;\">For the 10 random errors of this example we find a relatively strong negative bias. The <em>bias.coeff<\/em> function can also output histograms and boxplots of the bias coefficients for the input MRE.<\/p>\n<div class=\"SPOSTARBUST-Related-Posts\"><H3>Related Posts<\/H3><ul class=\"entry-meta\"><li class=\"SPOSTARBUST-Related-Post\"><a title=\"OR62 -The quest for greater forecasting accuracy: Perspectives from Statistics &#038; Machine Learning\" href=\"https:\/\/kourentzes.com\/forecasting\/2020\/10\/20\/or62-forecasting-stream\/\" rel=\"bookmark\">OR62 -The quest for greater forecasting accuracy: Perspectives from Statistics &#038; Machine Learning<\/a><\/li>\n<li class=\"SPOSTARBUST-Related-Post\"><a title=\"Tutorial for the nnfor R package\" href=\"https:\/\/kourentzes.com\/forecasting\/2019\/01\/16\/tutorial-for-the-nnfor-r-package\/\" rel=\"bookmark\">Tutorial for the nnfor R package<\/a><\/li>\n<li class=\"SPOSTARBUST-Related-Post\"><a title=\"R package: tsutils\" href=\"https:\/\/kourentzes.com\/forecasting\/2019\/01\/14\/r-package-tsutils\/\" rel=\"bookmark\">R package: tsutils<\/a><\/li>\n<\/ul><\/div><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In this post I introduce a new bias metric that has several desirable properties over traditional ones. When evaluating forecasting performance it is important to look at two elements: forecasting accuracy and bias. Although there has been substantial progress in the measurement of accuracy with various metrics being proposed, there has been rather limited progress\u2026 <span class=\"read-more\"><a href=\"https:\/\/kourentzes.com\/forecasting\/2014\/12\/17\/the-bias-coefficient-a-new-metric-for-forecast-bias\/\">Read More &raquo;<\/a><\/span><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[61,24,60,34,39],"_links":{"self":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts\/717"}],"collection":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/comments?post=717"}],"version-history":[{"count":0,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts\/717\/revisions"}],"wp:attachment":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/media?parent=717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/categories?post=717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/tags?post=717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->