This function fits a Neural AutoRegressive Fractionally Integrated Moving Average (NARFIMA) model to univariate time series. The model uses p Autoregressive terms, q moving average
terms, and a single hidden layer with size nodes. If p, q, or size are not specified, they are automatically
determined:
p is set to the number of significant Autoregressive coefficients estimated from an AR model.
q is set to the order of the moving average component from an ARFIMA model fitted to the residuals.
size is set to the floor of half the sum of p and q: $$size = \lfloor\frac{p + q}{2}\rfloor.$$
Exogenous variables can be included via xreg. If er is not
provided, it is computed from an ARFIMA model fitted to y. When y or xreg have missing values, the corresponding
rows and any dependent lagged rows are removed before fitting the model. Multiple neural network models are fitted, each initialized
with random weights, and the final model is obtained by averaging their outputs. Optionally, Box-Cox transformations can be applied
to stabilize variance, and inputs can be scaled to improve model convergence.
auto_narfima(
y,
er,
xreg = NULL,
p,
q,
P = 1,
size,
skip,
repeats = 1000,
lambda = 0.5,
lambdae = 0.5,
scale.inputs = TRUE,
...
)Returns an object of class "narfima", containing the following components:
The name of the input series.
A string describing the model parameters.
The fitted NARFIMA model.
The fitted values from the model.
The residuals from the model.
The seasonal frequency of the input series.
The number of Autoregressive terms used.
The number of moving average terms used.
The number of seasonal lags used.
The number of nodes in the hidden layer used in the neural network.
Indicates if the direct connections were used in the neural network.
The Box-Cox transformation parameter for the input series.
Scaling parameters for the input series.
The lags used for the input series.
The Box-Cox transformation parameter for the error term.
Scaling parameters for the error term.
The lags used for the error term.
Scaling parameters for the exogenous variables, if provided.
The input time series.
The transformed residual series
The exogenous variables used in the model, if provided.
Additional arguments passed to the neural network function.
A numeric vector or time series of class ts.
A numeric vector or time series object representing the series of residuals. If missing, it will be calculated from an ARFIMA model with exogenous variable (if provided).
An optional numeric matrix of exogenous variables to be included in the model (default is NULL).
Integer indicating the number of lags of the input series y.
Integer indicating the number of lags of the errors er.
Integer indicating the number of seasonal lags of the input series y (default is 1).
Integer specifying the number of nodes of the feed-forward neural networks with a single hidden layer.
Logical value indicating whether to use the direct connections in the neural network (default is TRUE).
Integer specifying the number of times to fit the neural network model (default is 1000).
Numeric value for the Box-Cox transformation parameter of y (default is 0.5).
Numeric value for the Box-Cox transformation parameter of er (default is 0.5).
Logical value indicating whether to standardize the inputs before fitting the model (default is TRUE).
Additional arguments passed to auto_narfima.
h <- 3
data <- EuStockMarkets[(nrow(EuStockMarkets) - 53):nrow(EuStockMarkets),4]
train <- data[1:(length(data) - h)]
test <- data[(length(data) - h + 1):length(data)]
narfima_model <- auto_narfima(train)
Run the code above in your browser using DataLab