{"id":1543,"date":"2019-01-14T13:03:02","date_gmt":"2019-01-14T13:03:02","guid":{"rendered":"http:\/\/kourentzes.com\/forecasting\/?p=1543"},"modified":"2019-01-14T14:33:08","modified_gmt":"2019-01-14T14:33:08","slug":"r-package-tsutils","status":"publish","type":"post","link":"https:\/\/kourentzes.com\/forecasting\/2019\/01\/14\/r-package-tsutils\/","title":{"rendered":"R package: tsutils"},"content":{"rendered":"<p>The <a href=\"https:\/\/cran.r-project.org\/package=tsutils\"><strong>tsutils<\/strong><\/a> package for R includes functions that help with time series exploration and forecasting, that were previously included in the <a href=\"https:\/\/github.com\/trnnick\/TStools\"><strong>TStools<\/strong><\/a> package that is only available on github. The name change was necessary as there is another package on CRAN with the same name. The objective of TStools is to provide a development and testing ground for various functions developed by my group that has led to the creation of various packages over time, such as <a href=\"https:\/\/cran.r-project.org\/package=smooth\"><strong>smooth<\/strong><\/a>, <a href=\"https:\/\/cran.r-project.org\/package=nnfor\"><strong>nnfor<\/strong><\/a> and now <strong>tsutils<\/strong>.<\/p>\n<p>The package provides functions to support the following tasks:<\/p>\n<ol style=\"list-style-type: decimal;\">\n<li>tests and visualisations that can help the modeller explore time series components and perform decomposition;<\/li>\n<li>modelling shortcuts, such as functions to construct lagmatrices and seasonal dummy variables of various forms;<\/li>\n<li>an implementation of the Theta method;<\/li>\n<li>tools to facilitate the design of the forecasting process, such as ABC-XYZ analyses;<\/li>\n<li>\u201cquality of life\u201d tools, such as treating time series for trailing and leading values.<\/li>\n<\/ol>\n<p>We will look at some of these functions here, to show you how <strong>tsutils<\/strong> can be helpful in your forecasting projects.<\/p>\n<div id=\"time-series-exploration\" class=\"section level2\">\n<h2>Time series exploration<\/h2>\n<p>Exploring your time series is an important step in modelling them. Some standard questions that one has to consider is whether a time series exhibits trend and\/or seasonality. First, we deal with the existence of trend. To look into this, it is useful to extranct the Centred Moving Average, and to do this you can use the functon <code>cmav()<\/code>.<\/p>\n<pre class=\"r\"><code>library(tsutils)\r\ncma &lt;- cmav(referrals) # referrals in a series included in the tsutils package.<\/code><\/pre>\n<p>The <code>cmav()<\/code> function offers a few useful arguments. By default it takes the length of the moving average from the time series information and sets it equal to its frequency. The user can override this by setting the argument <code>ma<\/code>. Another useful argument is <code>fill=c(TRUE,FALSE)<\/code> that instructs the function to fill the first and last observations of the centred moving average that are ommited in the calculation, due to the \u201ccentering\u201d. This is done using exponential smoothing (<code>ets()<\/code> from the <strong>forecast<\/strong> package). This is done by default. The argument <code>fast<\/code> restricts the number of exponential smoothing models considered to speed up the calculation. Finallly the argument <code>outplot=c(FALSE,TRUE)<\/code> provides a plot of the time sereis and the calculated centred moving average.<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1545\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-1-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>The CMA can help us identify whether there is a trend visually (see this <a href=\"http:\/\/kourentzes.com\/forecasting\/2018\/06\/20\/judgmental-selection-of-forecasting-models\/\">paper<\/a> for a discussion), but also to help us with statistical testing.<\/p>\n<p>The function <code>trendtest()<\/code> provides a logical (TRUE\/FALSE) answer for the presence of trend in a time series. It offers two alternatives, controlled by the argument <code>type<\/code>, which can take the values <code>\"aicc\"<\/code> or <code>\"cs\"<\/code> that tests by either fitting alternative exponential smoothing models and comparing their AICc or by using the Cox-Stuart test at 5% significance (you can run the test on its own using the function <code>coxstuart()<\/code>). The test can be conducted on the raw time series, or its CMA, the latter providing a cleaner signal of the low frequency components of the series, a major component of which is the trend. This is controlled by the argument <code>extract<\/code>. When this is <code>TRUE<\/code> the test is conducted on the CMA.<\/p>\n<pre class=\"r\"><code># Test on the CMA\r\ntrendtest(referrals, extract=TRUE)<\/code><\/pre>\n<pre><code>## [1] TRUE<\/code><\/pre>\n<pre class=\"r\"><code># Test on the raw time series\r\ntrendtest(referrals, extract=FALSE)<\/code><\/pre>\n<pre><code>## [1] FALSE<\/code><\/pre>\n<p>We can see that testing on the unfiltered data provides a different response. A further (experimental) argument is <code>mta<\/code> that instructs the function to use Multiple Temporal Aggregation, as proposed in the <a href=\"http:\/\/kourentzes.com\/forecasting\/2014\/04\/19\/improving-forecasting-by-estimating-time-series-structural-components-across-multiple-frequencies\/\">paper<\/a> that introduces <a href=\"http:\/\/kourentzes.com\/forecasting\/2017\/07\/04\/multiple-temporal-aggregation-the-story-so-far-part-iii\/\">MAPA<\/a>. Some evidence of the effect of this is provided <a href=\"http:\/\/kourentzes.com\/forecasting\/2017\/03\/30\/can-you-spot-a-trend-in-a-time-series\/\">here<\/a>, where it increases the accuracy of both approaches, AICc or Cox-Stuart testing.<\/p>\n<p>The function <code>seasplot()<\/code> is handy for exploring the seasonality of the time series. This provides various arguments for controlling the result. You can manually set the seasonal length (<code>ma<\/code> &#8211; otherwise it uses <code>frequency(y)<\/code>), the starting period of the seasonal cycle (<code>s<\/code> &#8211; also picked up from the time series object, if available), assume trend being present, absent or test (<code>trend<\/code>), type of decomposition when trend is present (<code>decomposition<\/code>) and using precaclculated CMA for the decomposition (<code>cma<\/code> &#8211; use <code>NULL<\/code> for calculating internally). If there is trend in the time series (as set by the user, or tested) then the time series is first de-trended according to the <code>decomposition<\/code> setting and then the seasonal plot is produced.<\/p>\n<p>There are a number of arguments to control the visualisation of seasonality. The argument <code>outplot<\/code> takes the following options:<\/p>\n<ul>\n<li>0, no plot;<\/li>\n<li>1, seasonal diagram;<\/li>\n<li>2, seasonal boxplots;<\/li>\n<li>3, seasonal subseries;<\/li>\n<li>4, seasonal distribution;<\/li>\n<li>5, seasonal density.<\/li>\n<\/ul>\n<p>In addition, one can provide various arguments to the plot function (consider in the <code>...<\/code> input), override the colouring (<code>colour<\/code>) and the labels (<code>labels<\/code>).<\/p>\n<pre><code>seasplot(referrals)<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1546\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils2-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>## Results of statistical testing\r\n## Evidence of trend: TRUE  (pval: 0)\r\n## Evidence of seasonality: TRUE  (pval: 0.002)<\/code><\/pre>\n<\/div>\n<div id=\"time-series-exploration\" class=\"section level2\">\n<p>The figure below exemplifies the available ploting alternatives.<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1547\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-3-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>The function provides some useful results, organised in a list: the trend and seasonal compoonents, the logical result of testing for their presence and the p-value of the tests. The trend is tested using the <code>coxstuart()<\/code> function, while the seasonality is tested by applying the Friedman test on the data as organised for `outplot=2\u2019, i.e.\u00a0is there evidence that at least one of the ranks of the distributions of the seasonal indices is significantly different from the rest?<\/p>\n<p>Finally, the function <code>decomp()<\/code> provides classical time series decomposition. Many of the arguments are similar to the <code>seasplot<\/code> function. Note that <code>type<\/code> now defines the method that is used to calculate the seasonal indices, which can be the arithmetic mean, median or a \u201cpure seasonal\u201d exponential smoothing model. That is, simply applying an exponential smoothing on the seasonal indices to smooth any randomness. As the later makes it complicated to extrapolate the seasonal component, the function accepts the argument <code>h<\/code> to provide predicted seasonal indices for h-steps ahead. Additionally for the calculation of the arithmetic mean one can winsorise extremes using the argument <code>w<\/code>.<\/p>\n<pre class=\"r\"><code>dc &lt;- decomp(referrals,outplot=TRUE)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1548\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-4-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<pre><code>names(dc)<\/code><\/pre>\n<pre><code>## [1] \"trend\"     \"season\"    \"irregular\" \"f.season\"  \"g\"<\/code><\/pre>\n<p>You can see that the output of the function is a list containing the various time series components. Note that <code>decomp()<\/code> does not test for the presence of seasonality will always extract a seasonal component.<\/p>\n<\/div>\n<div id=\"time-series-modelling\" class=\"section level2\">\n<h2>Time series modelling<\/h2>\n<p>There are a few fuctions that are designed with regression modelling in mind. The function <code>lagmatrix()<\/code> takes an input variable and constructs leads and lags as required.<\/p>\n<pre class=\"r\"><code>lags &lt;- lagmatrix(referrals, c(0,1,3:5))\r\nhead(lags,10)<\/code><\/pre>\n<pre><code>##         [,1]   [,2]   [,3]   [,4]   [,5]\r\n##  [1,] 933976     NA     NA     NA     NA\r\n##  [2,] 890852 933976     NA     NA     NA\r\n##  [3,] 912027 890852     NA     NA     NA\r\n##  [4,] 955852 912027 933976     NA     NA\r\n##  [5,] 821916 955852 890852 933976     NA\r\n##  [6,] 928176 821916 912027 890852 933976\r\n##  [7,] 979219 928176 955852 912027 890852\r\n##  [8,] 853812 979219 821916 955852 912027\r\n##  [9,] 792731 853812 928176 821916 955852\r\n## [10,] 913787 792731 979219 928176 821916<\/code><\/pre>\n<p>The first column is the original variable (lag 0), while the other columns are the requested lagged realisations. Leads are constructed by using negative numbers for the argument <code>lag<\/code>.<\/p>\n<p>The function <code>seasdummy()<\/code> creates seasonal dummy variables that can be either binary or trigonometric, as defined by the argument <code>type=c(\"bin\",\"trg\")<\/code>. Other arguments are the number of observations to create (<code>n<\/code>), the seasonal periodicity (<code>m<\/code>), a time series (<code>y<\/code>) that is an optional argument and can be useful to get the seasonal periodicity and the starting period information. The latter is useful when the seasonality is trigonometric to get the phase of the sines and cosines correctly. Argument <code>full<\/code> retains or drops the m-th dummy variable. For linear models that would typically be set to <code>full=FALSE<\/code>. For nonlinear models this becomes a somewhat more interesting modelling question. Some evidence for neural networks is provided in this <a href=\"http:\/\/kourentzes.com\/forecasting\/2016\/07\/09\/the-impact-of-special-days-in-call-arrivals-forecasting-a-neural-network-approach-to-modelling-special-days\/\">paper<\/a>.<\/p>\n<pre class=\"r\"><code>seasdummy(n=10,m=12)<\/code><\/pre>\n<pre><code>##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]\r\n##  [1,]    1    0    0    0    0    0    0    0    0     0     0\r\n##  [2,]    0    1    0    0    0    0    0    0    0     0     0\r\n##  [3,]    0    0    1    0    0    0    0    0    0     0     0\r\n##  [4,]    0    0    0    1    0    0    0    0    0     0     0\r\n##  [5,]    0    0    0    0    1    0    0    0    0     0     0\r\n##  [6,]    0    0    0    0    0    1    0    0    0     0     0\r\n##  [7,]    0    0    0    0    0    0    1    0    0     0     0\r\n##  [8,]    0    0    0    0    0    0    0    1    0     0     0\r\n##  [9,]    0    0    0    0    0    0    0    0    1     0     0\r\n## [10,]    0    0    0    0    0    0    0    0    0     1     0<\/code><\/pre>\n<p>For example, one can use these two functions to quick construct dynamic regression models.<\/p>\n<pre class=\"r\"><code>Xl &lt;- lagmatrix(referrals,c(0:2))\r\nXd &lt;- seasdummy(n=length(referrals),y=referrals)\r\nX &lt;- as.data.frame(cbind(Xl,Xd))\r\ncolnames(X) &lt;- c(\"y\",paste0(\"lag\",1:2),paste0(\"d\",1:11))\r\nfit &lt;- lm(y~.,X)\r\nsummary(fit)<\/code><\/pre>\n<pre><code>## \r\n## Call:\r\n## lm(formula = y ~ ., data = X)\r\n## \r\n## Residuals:\r\n##    Min     1Q Median     3Q    Max \r\n## -99439 -43116   7114  38919  98649 \r\n## \r\n## Coefficients:\r\n##              Estimate Std. Error t value Pr(&gt;|t|)    \r\n## (Intercept) 4.808e+05  1.695e+05   2.836  0.00672 ** \r\n## lag1        1.469e-01  1.337e-01   1.098  0.27760    \r\n## lag2        1.799e-01  1.397e-01   1.288  0.20394    \r\n## d1          1.751e+05  3.820e+04   4.584 3.38e-05 ***\r\n## d2          1.867e+05  4.161e+04   4.488 4.64e-05 ***\r\n## d3          2.445e+05  3.485e+04   7.015 7.75e-09 ***\r\n## d4          1.285e+05  4.204e+04   3.056  0.00369 ** \r\n## d5          1.840e+05  3.892e+04   4.727 2.10e-05 ***\r\n## d6          2.020e+05  3.709e+04   5.447 1.83e-06 ***\r\n## d7          2.054e+05  3.621e+04   5.673 8.39e-07 ***\r\n## d8          1.139e+05  3.613e+04   3.152  0.00282 ** \r\n## d9          1.698e+05  3.604e+04   4.713 2.21e-05 ***\r\n## d10         2.168e+05  3.749e+04   5.783 5.73e-07 ***\r\n## d11         1.616e+05  3.658e+04   4.418 5.83e-05 ***\r\n## ---\r\n## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1\r\n## \r\n## Residual standard error: 56250 on 47 degrees of freedom\r\n##   (2 observations deleted due to missingness)\r\n## Multiple R-squared:  0.5882, Adjusted R-squared:  0.4743 \r\n## F-statistic: 5.165 on 13 and 47 DF,  p-value: 1.365e-05<\/code><\/pre>\n<p>Obviously, one might prefer to have the seasonal dummies as a factor variable, when these are to be coded as binary dummy variables. Users of the <strong>nnfor<\/strong> package may recognise these two functions. In the next release of that package, both functions will be moved to the <strong>tsutils<\/strong> (this is already done in the <a href=\"https:\/\/github.com\/trnnick\/nnfor\">development<\/a> version).<\/p>\n<p>The function <code>residout()<\/code> looks at model residuals from a control chart point of view and identifies outlying ones. You can manually set the threshold over which the <em>standardised<\/em> residuals will be considered outlier (<code>t<\/code>) and whether to produce a plot (<code>outplot<\/code>).<\/p>\n<pre class=\"r\"><code>rsd &lt;- residout(residuals(fit))<\/code><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1549\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-5-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/pre>\n<p>If there are outliers, their location and values are provided in the outputted list.<\/p>\n<pre class=\"r\"><code>err &lt;- rnorm(20)\r\nerr[5] &lt;- err[5]+5\r\nresidout(err,outplot=FALSE)$location<\/code><\/pre>\n<pre><code>## [1] 5<\/code><\/pre>\n<p>The idea behind this function is to identify outliers so that the modeller can construct dummies to account for them or manipulate them otherwise.<\/p>\n<p>A somewhat more exotic function is <code>getOptK<\/code> that provides the optimal temporal aggregation level for AR(1), MA(1) and ARMA(1,1) processes. The user defines the type of data generating process that we expect (<code>type=c(\"ar\",\"ma\",\"arma\")<\/code>) and the maximum aggregation level (<code>m<\/code>). The output is the theoretically optimal aggregation level.<\/p>\n<pre class=\"r\"><code>getOptK(referrals) # This time series is clearly not an AR(1)!<\/code><\/pre>\n<pre><code>## [1] 9<\/code><\/pre>\n<p>For a discussion of the pros and cons of this theoretical calculation see this <a href=\"http:\/\/kourentzes.com\/forecasting\/2017\/04\/22\/demand-forecasting-by-temporal-aggregation-using-optimal-or-multiple-aggregation-levels\/\">paper<\/a>. My personal view is that Multiple Temporal Aggregation as implemented in <a href=\"https:\/\/cran.r-project.org\/package=MAPA\"><strong>MAPA<\/strong><\/a> or Temporal Hierarchies (<a href=\"https:\/\/cran.r-project.org\/package=thief\"><strong>thief<\/strong><\/a>) is a less risky modelling approach and therefore more desirable for practice.<\/p>\n<p>The function <code>theta()<\/code> provides an implementation of the classical Theta method, with a few modifications. The workflow matches the one in the <strong>forecast<\/strong> package:<\/p>\n<pre class=\"r\"><code>fit &lt;- theta(referrals)\r\nfrc &lt;- forecast.theta(fit,h=20)\r\nplot(frc)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1550\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-6-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>This implementation of the Theta method tests for seasonality and trend. Seasonal decomposition can be done either additively or multiplicatively and the seasonality is treated as a pure seasonal model. The various Theta components can be optimised using different cost functions. The originally proposed Theta method always assumed multiplicative seasonality and presence of trend, while all theta lines were optimised using MSE and seasonality was estimated using classical decomposition and arithmetic mean. The various arguments of the function can control how <code>theta()<\/code> operates: <code>m<\/code> can be used to manually set the seasonal length, <code>sign.level<\/code> the significance level for the statistical tests, <code>cost0<\/code> to <code>cost2<\/code> the cost function for the various components of the model, <code>multiplicative<\/code> the type of decomposition used and <code>cma<\/code> an optional pre-calculated Centred Moving Average used for decomposition and testing. Also note that since impolementation is not based on a model, it does not provide prediction intervals or information criteria.<\/p>\n<p>If you are a user of <strong>thief<\/strong> (if not give it a try!) the function <code>theta.thief()<\/code> integrates both packages:<\/p>\n<pre class=\"r\"><code>library(thief)\r\nthief(referrals,forecastfunction=theta.thief)<\/code><\/pre>\n<pre><code>##            Jan       Feb       Mar       Apr       May       Jun       Jul\r\n## 2013                                                             1035418.8\r\n## 2014  955320.7  957015.3 1067922.5  984519.0 1019637.9 1027866.9 1040235.2\r\n## 2015  959464.4  961167.2 1072865.8  988823.4 1024207.9 1032495.2          \r\n##            Aug       Sep       Oct       Nov       Dec\r\n## 2013  943204.9  991756.3 1031436.6  987854.5  819194.1\r\n## 2014  947299.6  996207.8 1036200.5  992380.8  822408.6\r\n## 2015<\/code><\/pre>\n<p>In this case temporal hierarchy forecasts are constructed using the Theta method, as implmemented in <strong>tsutils<\/strong>, at all temporal aggregation levels.<\/p>\n<p>One of the major tasks in producing the appropriate forecasts for a time series is evaluating the performance of different models\/methods. The <code>nemenyi()<\/code> function is helpful to perform nonparametric multiple comparisons testing. There are two considerations. First, some difference in summary performance statistics does not always mean that one forecast is indeed preferable, as differences may still be due to randomeness, and more evidence is necessary. Second, doing repeated pairwise testing between methods does not result in the desired significance in the results, as by doing this repetition is distorting your testing probabilities. The <code>nemenyi()<\/code> function first performs a Friedman test to establish that at least one method performs significantly different and then uses the post-hoc Nemenyi test to group methods by similar performance. Both tests are nonparametric, and therefore the distribution of the performance metric is not an issue.<\/p>\n<pre class=\"r\"><code>x &lt;- matrix( rnorm(50*4,mean=0,sd=1), 50, 4) # Generate some performance statistics\r\nx[,2] &lt;- x[,2]+1 \r\nx[,3] &lt;- x[,3]+0.7\r\nx[,4] &lt;- x[,4]+0.5\r\ncolnames(x) &lt;- c(\"Method A\",\"Method B\",\"Method C - long name\",\"Method D\")\r\nnemenyi(x)\r\n<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1562\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-12-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/code><\/pre>\n<pre><code>## Friedman and Nemenyi Tests\r\n## The confidence level is 5%\r\n## Number of observations is 50 and number of methods is 4\r\n## Friedman test p-value: 2e-04 - Ha: Different\r\n## Critical distance: 0.6633<\/code><\/pre>\n<p>The plot is fairly easy to read. Any for methods that are joined by a horizontal there is no evidence of statistically significant differences. There are multiple lines, as we can start measuring from different methods. The test is simple. For any method that is within plus\/minus the critical distance (CD in the plot) from the mean rank (the values next to method names) there is no evidence of differences. The function provides different plot styles, using the argument <code>plottype<\/code>. This can be used to minic the \u201cmultiple comparison with the best\u201d (<code>plottype=\"mcb\"<\/code> or <code>plottype=\"vmcb\"<\/code> for vertical alternative), the \u201cline plot\u201d above (<code>plottype=\"line\"<\/code> or <code>plottype=\"vline\"<\/code>), a detailed comparison (<code>plottype=\"matrix\"<\/code>) or output no visualisation (<code>plottype=\"none\"<\/code>).<br \/>\n<a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1563\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutil-13-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><br \/>\nThe <code>mcb<\/code> visualisation shows the performance of the various methods seperately. The dot in the middle is the mean rank of the method and the lines span te critical distance (half above and half below). For any other method that its boundaries are crossed there is no evidence of significant differences. The <code>matrix<\/code> shows on the vertical axis all methods sorted according to mean rank. On the horizontal axis they are sorted as in the input array. The balck cell is the method from which we measure and in a row (or column) any methods in blue belong to the same group of perofrmance. For example, in all the plots above, method A has no differences from d and c. Method d similarly is grouped together with a and c. When we measure from c, on the other hand, we have no evidence for significant differences from any method. When we measure from b, then both a and d have significant differences. If we are interested in the best performing group then the <code>mcb<\/code> visualisation is the simplest to consult. Otherwise <code>matrix<\/code> is the most detailed and <code>line<\/code>\/<code>vline<\/code> is a compromise between the two.<\/p>\n<\/div>\n<div id=\"forecasting-process-modelling\" class=\"section level2\">\n<h2>Forecasting process modelling<\/h2>\n<p>Beyond various modelling functions, the package <strong>tsutils<\/strong> offers some functions for analysing the forecasting process. More specifically it helps to conduct ABC-XYZ analyses. This is done using the functions <code>abc()<\/code>, <code>xyz()<\/code> and <code>abcxyz()<\/code>.<\/p>\n<p>Starting with the ABC part of the analysis, given an array of time series, where each column is a time series, you can use:<\/p>\n<pre class=\"r\"><code>x &lt;- abs(matrix(cumsum(rnorm(5400,0,1)),36,150)) # Construct some random data\r\nABC &lt;- abc(x)\r\nprint(ABC)<\/code><\/pre>\n<pre><code>## ABC analysis\r\n##          Importance %\r\n## A (20%): 39.678\r\n## B (30%): 43.061\r\n## C (50%): 17.261<\/code><\/pre>\n<p>We can also plot the output, providing the concentration in each class.<\/p>\n<pre class=\"r\"><code>plot(ABC)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1551\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-7-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Alternatively, the input can be a vector that contains the importance index for each series. The reader is referred to Ord K., Fildes R., Kourentzes N. (2017) <a href=\"http:\/\/kourentzes.com\/forecasting\/2017\/10\/16\/new-forecasting-book-principles-of-business-forecasting-2e\/\">Principles of Business Forecasting<\/a>, 2e. Wessex Press Publishing Co., p.515-518 for details of how to use the ABC analysis, as well as the XYZ analysis that follows.<\/p>\n<p>The user can set custom percentages for each class, or change the number of classes with the argument <code>prc<\/code>. For example:<\/p>\n<pre class=\"r\"><code>plot(abc(x,prc=c(0.1,0.15,0.25,0.5)))<\/code><\/pre>\n<\/div>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1552\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-8-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<div id=\"forecasting-process-modelling\" class=\"section level2\">\n<p>The function <code>xyz()<\/code> looks at the forecastability side. In addition to the arguments in <code>abc()<\/code> the user can select the type of forecast used to generate errors (<code>type<\/code>) and the seasonal periodicity of the series (<code>m<\/code>). For a discussion see the aforementioned reference and <a href=\"http:\/\/kourentzes.com\/forecasting\/2016\/10\/15\/abc-xyz-analysis-for-forecasting\/\">here<\/a>. By default the naive and seasonal naive methods are used (<code>type=\"naive\"<\/code>), but the user can opt to rely on exponential smoothing (<code>type=\"ets\"<\/code>). The option to use the coefficient of variation is available (<code>type=\"cv\"<\/code>), but I strongly advise against using it (see the previous references).<\/p>\n<pre class=\"r\"><code>XYZ &lt;- xyz(x,m=12)\r\nplot(XYZ)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1553\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-9-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>One can combine both analyses with the function <code>abcxyz()<\/code>. This can also accept a vector of forecast errors (with the argument <code>error<\/code>) that are distributed to each class of items. This vector must be equal length to the columns used to construct the ABC and XYZ analyses.<\/p>\n<pre class=\"r\"><code>abcxyz(ABC,XYZ)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1557\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-10-1-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<pre><code>## $class\r\n##    Z  Y  X\r\n## A  0  0 30\r\n## B  0  0 45\r\n## C 30 45  0\r\n## \r\n## $error\r\n## NULL<\/code><\/pre>\n<\/div>\n<div id=\"quality-of-life-functions\" class=\"section level2\">\n<h2>Quality of life functions<\/h2>\n<p>The package includes some QoL functions. The function <code>geomean()<\/code> calculates the geometric mean and accepts the same arguments as the <code>mean()<\/code>.<\/p>\n<pre class=\"r\"><code>geomean(c(0.5,1,1.5))<\/code><\/pre>\n<pre><code>## [1] 0.9085603<\/code><\/pre>\n<pre class=\"r\"><code>mean(c(0.5,1,1.5))<\/code><\/pre>\n<pre><code>## [1] 1<\/code><\/pre>\n<p>The function <code>leadtrail()<\/code> can remove leading or trailing zeros or NAs as requested. This is controlled by the arguments<code>rm<\/code>, <code>lead<\/code> and <code>trail<\/code>.<\/p>\n<pre class=\"r\"><code>x &lt;- c(rep(0,2),rnorm(5),rep(0,2))\r\nprint(x)<\/code><\/pre>\n<pre><code>## [1]  0.0000000  0.0000000 -0.9519769 -1.1978381 -0.9596107 -1.6142629\r\n## [7]  0.5855328  0.0000000  0.0000000<\/code><\/pre>\n<pre class=\"r\"><code>leadtrail(x)<\/code><\/pre>\n<pre><code>## [1] -0.9519769 -1.1978381 -0.9596107 -1.6142629  0.5855328<\/code><\/pre>\n<p>The function <code>wins()<\/code> winsorises vectors and accepts the argument <code>p<\/code> to control how many observations are treated. If <code>p<\/code> is less than 1, then it is interpretted as a percentage. If it is bigger or equal to 1, then it is treated as number of observations.<\/p>\n<pre class=\"r\"><code>x &lt;- sort(round(runif(10)*10))\r\nprint(x)<\/code><\/pre>\n<pre><code>##  [1] 0 1 1 1 3 7 8 8 9 9<\/code><\/pre>\n<pre class=\"r\"><code>wins(x,2)<\/code><\/pre>\n<pre><code>##  [1] 1 1 1 1 3 7 8 8 8 8<\/code><\/pre>\n<pre class=\"r\"><code>wins(x,0.1)<\/code><\/pre>\n<pre><code>##  [1] 1 1 1 1 3 7 8 8 9 9<\/code><\/pre>\n<p>There are two vectorised versions <code>colWins()<\/code> and <code>rowWins()<\/code> to speed up calculations for large arrays.<\/p>\n<p>Finally, the function <code>lambdaseq()<\/code> is meant to be used with LASSO and similar. Given some response target <code>y<\/code> and regressors <code>x<\/code> it calculates a sequence of lambdas from the OLS solution to the penalty that removes all regressors from the model. If weighted LASSO will be used, then the argument <code>weigth<\/code> can beused to account for that. To switch to ridge regression or elastic nets use the argument <code>alpha<\/code>. How many lambdas are produced (<code>nLambda<\/code>) and how the lambda decreases (<code>lambdaRatio<\/code>) can be controlled. The argument <code>standardise<\/code> preprocess the variables, while the arguement <code>addZeroLamda<\/code> does as it says and adds the OLS solution lambda in the output vector.<\/p>\n<pre class=\"r\"><code>y &lt;- mtcars[,1]\r\nx &lt;- as.matrix(mtcars[,2:11])\r\nlambda &lt;- lambdaseq(x, y)[[1]]\r\nplot(lambda)<\/code><\/pre>\n<p><a href=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-1556\" src=\"http:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1.png\" alt=\"\" width=\"500\" height=\"357\" srcset=\"https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1.png 1344w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1-150x107.png 150w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1-300x214.png 300w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1-768x549.png 768w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1-1024x731.png 1024w, https:\/\/kourentzes.com\/forecasting\/wp-content\/uploads\/2019\/01\/tsutils-11-1-660x471.png 660w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>This can be directly used with the <strong>glmnet<\/strong> package, or with custom shrinkage estimators (the motivation behind building this function!).<\/p>\n<pre class=\"r\"><code>library(glmnet)\r\nfit.lasso &lt;- cv.glmnet(x, y, lambda = lambda)<\/code><\/pre>\n<p>Users of <strong>TStools<\/strong> will not find any new functionality in <strong>tsutils<\/strong> yet. Under the hood there are various improvements and better documentation. Where necessary, the functions point to useful references and examples. Most importantly, these functions are now in CRAN and <em>safe<\/em> to use! The plan is to keep expanding <strong>tsutils<\/strong> with more functions that graduate from the development <strong>TStools<\/strong>.<\/p>\n<p><strong>Happy forecasting!<\/strong><\/p>\n<\/div>\n<div class=\"SPOSTARBUST-Related-Posts\"><H3>Related Posts<\/H3><ul class=\"entry-meta\"><li class=\"SPOSTARBUST-Related-Post\"><a title=\"Elucidate structure in intermittent demand time series\" href=\"https:\/\/kourentzes.com\/forecasting\/2020\/05\/25\/elucidate-structure-in-intermittent-demand-time-series\/\" rel=\"bookmark\">Elucidate structure in intermittent demand time series<\/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=\"Update for nnfor: reuse and retrain models\" href=\"https:\/\/kourentzes.com\/forecasting\/2017\/12\/11\/update-for-nnfor-reuse-and-retrain-models\/\" rel=\"bookmark\">Update for nnfor: reuse and retrain models<\/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>The tsutils package for R includes functions that help with time series exploration and forecasting, that were previously included in the TStools package that is only available on github. The name change was necessary as there is another package on CRAN with the same name. The objective of TStools is to provide a development and\u2026 <span class=\"read-more\"><a href=\"https:\/\/kourentzes.com\/forecasting\/2019\/01\/14\/r-package-tsutils\/\">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":[39,51,42],"_links":{"self":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts\/1543"}],"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=1543"}],"version-history":[{"count":7,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts\/1543\/revisions"}],"predecessor-version":[{"id":1565,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/posts\/1543\/revisions\/1565"}],"wp:attachment":[{"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/media?parent=1543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/categories?post=1543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kourentzes.com\/forecasting\/wp-json\/wp\/v2\/tags?post=1543"}],"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. -->