Description Usage Arguments Details Value Author(s) References Examples

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
ConsRegArima(...)
## Default S3 method:
ConsRegArima(x, y, order, seasonal, optimizer,
LOWER = NULL, UPPER = NULL, penalty = 1000, constraints = NULL,
ini.pars.coef, model_fit = NULL, ...)
## S3 method for class '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, ...) |

`x` |
matrix of predictive variables |

`y` |
vector of outcome variable |

`order` |
Arma component (p, q) |

`seasonal` |
A specification of the seasonal part of the ARMA model (P,Q), plus the period (which defaults to 1). |

`optimizer` |
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) |

`LOWER` |
(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 |

`UPPER` |
(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 |

`penalty` |
(default 1000) penalty to the objective function if some constraints do not fullfill |

`constraints` |
vector of constraints (see details) |

`ini.pars.coef` |
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. |

`model_fit` |
object of class |

`formula` |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted |

`data` |
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` |
na.action to the data |

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.

An object of class "`ConsRegArima`

".

`coefficients` |
Coefficients (regression + arma errors) |

`hessian` |
hessian matrix if the optimizer can return it |

`optimizer` |
optimizer object return (see details of each optimization package) |

`optimizer.name` |
name of the optimizer |

`df` |
nrow(data) - number of coefficients |

`rank` |
number of coefficients |

`objective_function` |
objective_function used |

`model` |
A list representing the Kalman Filter used in the fitting |

`sigma2` |
the MLE of the innovations variance |

`residuals` |
residuals of the model |

`fitted` |
fitted values of the model |

`fitted_regression` |
fitted values only of the regression part |

`fitted_arima` |
fitted values only of the arma part |

`metrics` |
Accuracy metrics of the model (accuracy function of the forecast package) |

`call` |
the matched call |

`y` |
objective series |

`x` |
regressors |

`formula` |
formula term |

`aic` |
the AIC value (see details) |

`bic` |
the BIC value |

`aicc` |
the AICc value |

Josep Puig Salles

Peiris, M. & Perera, B. (1988), On prediction with fractionally Hyndman RJ, Khandakar Y (2008). “Automatic time series forecasting: the forecast package for R.”

1 2 3 4 5 6 7 8 9 10 | ```
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
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.