ConsRegArima is a function that allows to estimate a regression model with errors following an ARMA process (p,q). It allows the introduction of restrictions (both lower and upper limits) and restrictions between the coefficients (in the form, for example, of a>b). Largely a wrapper for the arima function in the stats package but easier to include regressors.
ConsRegArima(...)# S3 method for default
ConsRegArima(x, y, order, seasonal, optimizer,
LOWER = NULL, UPPER = NULL, penalty = 1000, constraints = NULL,
ini.pars.coef, model_fit = NULL, ...)
# S3 method for formula
ConsRegArima(formula, data = list(),
optimizer = c("solnp"), order = c(0, 0), seasonal = list(order =
c(0, 0), period = NA), LOWER = NULL, UPPER = NULL, penalty = 1000,
constraints = NULL, ini.pars.coef = NULL, na.action = "na.omit",
...)
additional parameters passed in the optimizer (number of iterations, ...)
matrix of predictive variables
vector of outcome variable
Arma component (p, q)
A specification of the seasonal part of the ARMA model (P,Q), plus the period (which defaults to 1).
Optimizer package used for fit the model (include bayesian and genetic algorithm optimization). Possible values are: "solnp" (default) (Rsolnp), "gosonlp" (Rsolnp), "optim" (stats::optim), "nloptr" (nloptr), DEoptim ("DEoptim"), "dfoptim" (dfoptim), "mcmc" (FME::modMCMC), "MCMCmetrop" (MCMCpack::MCMCmetrop1R), 'adaptMCMC'(adaptMCMC::MCMC), "GA" (GA package), "GenSA" (GenSA package)
(default NULL) vector of lower bounds for the coefficients. If the lenght of LOWER is not equal with the length of the coeefficients, then, the rest will be equal to -Inf
(default NULL) vector of lower bounds for the coefficients. If the lenght of UPPER is not equal with the length of the coeefficients, then, the rest will be equal to +Inf
(default 1000) penalty to the objective function if some constraints do not fullfill
vector of constraints (see details)
vector of initial parameters. In case there is some constraint, then the ini.pars.coef should fulfill the constraints. This vector is only for regression component.
object of class ConsRegArima
to update the Arma part
and fix the coefficient from a previous model
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called.
na.action to the data
An object of class "ConsRegArima
".
Coefficients (regression + arma errors)
hessian matrix if the optimizer can return it
optimizer object return (see details of each optimization package)
name of the optimizer
nrow(data) - number of coefficients
number of coefficients
objective_function used
A list representing the Kalman Filter used in the fitting
the MLE of the innovations variance
residuals of the model
fitted values of the model
fitted values only of the regression part
fitted values only of the arma part
Accuracy metrics of the model (accuracy function of the forecast package)
the matched call
objective series
regressors
formula term
the AIC value (see details)
the BIC value
the AICc value
Several optimizers of various R packages are implemented, including methods typically used in Bayesian regressions like Markov Chain Monte Carlo simulation.
Constraints will be a string: For example, if x1 and x2 are two coefficient names, then a constraint could be: "x1 > x2" or "x1+x2 > 2". For some constraints, one can write: "x1+x2>2, x1 > 1". Each constraint will be separate by commas.
Important: if there are some constraints that do not fulfill in a model without those constraints,
it is recommended to use ini.pars.coef
parameter to set initial values that fulfill constraints.
See the example
On the other hand, aic value is computed as auto.arima function computes the AIC when method == 'CSS':
$$ AIC = n * log(sigma2) + npar * 2 $$
Where npa
r I set the number of coefficients.
Peiris, M. & Perera, B. (1988), On prediction with fractionally Hyndman RJ, Khandakar Y (2008). <U+201C>Automatic time series forecasting: the forecast package for R.<U+201D>
# NOT RUN {
data('series')
fit1 = ConsRegArima(formula = y ~ x1+x2 +x3+x4,
order = c(2, 1), data = series)
summary(fit1)
fit2 = ConsRegArima(formula = y ~ x1+x2 +x3+x4, order = c(2, 1),
data = series, constraints = '(x3 +.1) > x1',
ini.pars.coef = c(.96, .2, -.8, .4), UPPER = 1, LOWER = -1)
fit1$coefficients
fit2$coefficients
# }
Run the code above in your browser using DataLab