The package greybox contains functions for model building, which is currently done via the model selection and combinations based on information criteria. The resulting model can then be used in analysis and forecasting.
There are several groups of functions in the package.
Regression model functions
- alm - advanced linear regression model that implements likelihood estimation of parameters for Normal, Laplace, Asymmetric Laplace, Logistic, Student's t, S, Folded Normal, Log Normal, Box-Cox Normal, Inverse Gaussian, Chi-Squared, Beta, Poisson, Negative Binomial, Cumulative Logistic and Cumulative Normal distributions. In a sense this is similar to
glm()function, but with a different set of distributions and with a focus on forecasting.
- stepwise - function implements stepwise IC based on partial correlations.
- lmCombine - function combines the regression models from the provided data, based on IC weights and returns the combined alm object.
Exogenous variables transformation functions
- xregExpander - function produces lags and leads of the provided data.
- xregTransformer - function produces non-linear transformations of the provided data (logs, inverse etc).
- xregMultiplier - function produces cross-products of the variables in the matrix. Could be useful when exploring interaction effects of dummy variables.
The data analysis functions
- cramer - calculates Cramer's V for two categorical variables. Plus tests the significance of such association.
- mcor - function returns the coefficients of multiple correlation between the variables. This is useful when measuring association between categorical and numerical variables.
- association (aka 'assoc()') - function returns matrix of measures of association, choosing between cramer(), mcor() and cor() depending on the types of variables.
- determination (aka 'determ()') - function returns the vector of coefficients of determination (R^2) for the provided data. This is useful for the diagnostics of multicollinearity.
- tableplot - plots the graph for two categorical variables.
- spread - plots the matrix of scatter / boxplot / tableplot diagrams - depending on the type of the provided variables.
- graphmaker - plots the original series, the fitted values and the forecasts.
Models evaluation functions
- ro - rolling origin evaluation (see the vignette).
- rmc - Regression for Multiple Comparison of forecasting methods. Can be used, for example, when RelMAE is calculated for several forecasting methods and an analysis of statistical significance in accuracy of methods needs to be carried out. This can be especially useful when you have a lot of methods to compare. The test is faster than Nemenyi in this case and becomes more powerful and accurate.
- measures - the error measures for the provided forecasts. Includes MPE, MAPE, MASE, sMAE, sMSE, RelMAE, RelRMSE, MIS, sMIS, RelMIS, pinball and others.
- qlaplace, dlaplace, rlaplace, plaplace - functions for Laplace distribution.
- qalaplace, dalaplace, ralaplace, palaplace - functions for Asymmetric Laplace distribution.
- qs, ds, rs, ps - functions for S distribution.
- qfnorm, dfnorm, rfnorm, pfnorm - functions for folded normal distribution.
- qtplnorm, dtplnorm, rtplnorm, ptplnorm - functions for three parameter log normal distribution.
- qbcnorm, dbcnorm, rbcnorm, pbcnorm - functions for Box-Cox normal distribution (discussed in Box & Cox, 1964).
Methods for the introduced and some existing classes:
- pointLik - point likelihood method for the time series models.
- pAIC, pAICc, pBIC, pBICc - respective point values for the information criteria, based on pointLik.
- summary - returns summary of the regression (either selected or combined).
- vcov - covariance matrix for combined models. This is an approximate thing. The real one is quite messy and not yet available.
- confint - confidence intervals for combined models.
- predict, forecast - point and interval forecasts for the response variable. forecast method relies on the parameter h (the forecast horizon), while predict is focused on the newdata. See vignettes for the details.
- nParam - returns number of estimated parameters in the model (including variance, location, shift).
- getResponse - returns the response variable from the model.
- plot - plots several graphs for the analysis of the residuals (see documentation for more details).
- AICc - AICc for regression with normally distributed residuals.
- BICc - BICc for regression with normally distributed residuals.
- is.greybox, is.alm etc. - functions to check if the object was generated by respective functions.
- lmDynamic - linear regression with time varying parameters based on pAIC.
The stable version of the package is available on CRAN, so you can install it by running:
A recent, development version, is available via github and can be installed using "devtools" in R. First make sure that you have devtools:
and after that run: