<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/greybox-package-for-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://forecasting.svetunkov.ru/en/2018/05/04/greybox-package-for-r/"> R – Modern Forecasting</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i0.wp.com/forecasting.svetunkov.ru/wp-content/uploads/2018/05/greybox2.png?ssl=1" target="_blank"><img sizes="(max-width: 260px) 100vw, 260px" src="https://i0.wp.com/forecasting.svetunkov.ru/wp-content/uploads/2018/05/greybox2-260x300.png?resize=260%2C300&ssl=1" alt="Hexagon for greybox" width="260" class="wp-image-1719" data-recalc-dims="1" height="300"></a></p>
<p>I am delighted to announce a new package on CRAN. It is called “greybox”. I know, what my American friends will say, as soon as they see the name – they will claim that there is a typo, and that it should be “a” instead of “e”. But in fact no mistake was made – I used British spelling for the name, and I totally understand that at some point I might regret this…</p>
<p>So, what is “greybox”? Wikipedia <a rel="nofollow" href="https://en.wikipedia.org/wiki/Grey_box_model" target="_blank">tells us that grey box</a> is a model that “combines a partial theoretical structure with data to complete the model”. This means that almost any statistical model can be considered as a grey box, thus making the package potentially quite flexible and versatile.</p>
<p>But why do we need a new package on CRAN?</p>
<p>First, there were several functions in <a rel="nofollow" href="https://forecasting.svetunkov.ru/en/tag/smooth/" target="_blank">smooth</a> package that did not belong there, and there are several functions in <a rel="nofollow" href="https://github.com/trnnick/TStools" target="_blank">TStools</a> package that can be united with a topic of model building. They focus on the multivariate regression analysis rather than on state-space models, time series smoothing or anything else. It would make more sense to find them their own <del>home</del> package. An example of such a function is </p>
<pre>ro()</pre>
<p> – <a rel="nofollow" href="https://cran.r-project.org/web/packages/greybox/vignettes/ro.html" target="_blank">Rolling Origin</a> – function that Yves and I wrote in 2016 on our way to the International Symposium on Forecasting. Arguably this function can be used not only for assessing the accuracy of forecasting models, but also for the variables / model selection.</p>
<p>Second, in one of my side projects, I needed to work more on the multivariate regressions, and I had several ideas I wanted to test. One of those is creating a combined multivariate regression from several models using information criteria weights. The existing implementations did not satisfy me, so I ended up writing a function </p>
<pre>combiner()</pre>
<p> that does that. In addition, our research together with Yves Sagaert indicates that there is a nice solution for a fat regression problem (when the number of parameters is higher than the number of observations) using information criteria. Uploading those function in </p>
<pre>smooth</pre>
<p> did not sound right, but having a </p>
<pre>greybox</pre>
<p> helps a lot. There are other ideas that I have in mind, and they don’t fit in the other packages.</p>
<p>Finally, I could not find satisfactory (from my point of view) packages on CRAN that would focus on multivariate model building and forecasting – the usual focus is on analysis instead (including time series analysis). The other thing is the obsession of many packages with p-values and hypotheses testing, which was yet another motivator for me to develop a package that would be completely hypotheses-free (at 95% level). As a result, if you work with the functions from </p>
<pre>greybox</pre>
<p>, you might notice that they produce confidence intervals instead of p-values (because I find them more informative and useful). Finally, I needed good instruments for the promotional modelling for several projects, and it was easier to implement them myself than to compile them from different functions from different packages.</p>
<p>Keeping that in mind, it makes sense to briefly discuss what is already available there. I’ve already discussed how </p>
<pre>xregExpander()</pre>
<p> and </p>
<pre>stepwise()</pre>
<p> functions work <a rel="nofollow" href="https://forecasting.svetunkov.ru/en/2018/02/10/smooth-package-for-r-common-ground-part-iv-exogenous-variables-advanced-stuff/" target="_blank">in one of the previous posts</a>, and these functions are now available in </p>
<pre>greybox</pre>
<p> instead of </p>
<pre>smooth</pre>
<p>. However, I have not covered either </p>
<pre>combiner()</pre>
<p> or </p>
<pre>ro()</pre>
<p> functions yet. While </p>
<pre>combiner()</pre>
<p> is still under construction and works only for normal cases (fat regression can be solved, but not 100% efficiently), </p>
<pre>ro()</pre>
<p> has worked efficiently for several years already. So I created a detailed <a rel="nofollow" href="https://cran.r-project.org/web/packages/greybox/vignettes/ro.html" target="_blank">vignette</a>, explaining what is rolling origin, how the function works and how to use it. So, if you are interested in finding out more, <a rel="nofollow" href="https://cran.r-project.org/web/packages/greybox/vignettes/ro.html" target="_blank">check it out on CRAN</a>.</p>
<p>As a wrap up, </p>
<pre>greybox</pre>
<p> package is focused on model building and forecasting and from now on will be periodically updated.</p>
<p>As a final note, I plan to do the following in </p>
<pre>greybox</pre>
<p> in future releases:</p>
<ol>
<li>Move
<pre>nemenyi()</pre>
<p> function from <a rel="nofollow" href="https://github.com/trnnick/TStools" target="_blank">TStools</a> to <a rel="nofollow" href="https://github.com/config-i1/greybox" target="_blank">greybox</a>;
<li>Develop functions for promotional modelling;</li>
<li>Write a function for multiple correlation coefficients (will be used for multicollinearity analysis);</li>
<li>Implement variables selection based on rolling origin evaluation;</li>
<li>Stepwise regression and combinations of models, based on Laplace and the other distributions;</li>
<li>AICc for Laplace and the other distributions;</li>
<li>Solve fat regression problem via combination of regression models (sounds crazy, right?);</li>
<li>
<pre>xregTransformer</pre>
<p> – Non-linear transformation of the provided xreg variables;
<li>Other cool stuff.</li>

<p>If you have any thoughts on what to implement, leave a comment – I will consider your idea.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://forecasting.svetunkov.ru/en/2018/05/04/greybox-package-for-r/"> R – Modern Forecasting</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/7BxbMpEzOu4" height="1"></a></div></ol>