# NNS.VAR: NNS VAR In NNS: Nonlinear Nonparametric Statistics

## Description

Nonparametric vector autoregressive model incorporating NNS.ARMA estimates of variables into NNS.reg for a multi-variate time-series forecast.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```NNS.VAR( variables, h, tau = 1, dim.red.method = "cor", obj.fn = expression(sum((predicted - actual)^2)), objective = "min", status = TRUE, ncores = NULL, nowcast = FALSE ) ```

## Arguments

 `variables` a numeric matrix or data.frame of contemporaneous time-series to forecast. `h` integer; 1 (default) Number of periods to forecast. `(h = 0)` will return just the interpolated and extrapolated values. `tau` positive integer [ > 0]; 1 (default) Number of lagged observations to consider for the time-series data. Vector for single lag for each respective variable or list for multiple lags per each variable. `dim.red.method` options: ("cor", "NNS.dep", "NNS.caus", "all") method for reducing regressors via NNS.stack. `(dim.red.method = "cor")` (default) uses standard linear correlation for dimension reduction in the lagged variable matrix. `(dim.red.method = "NNS.dep")` uses NNS.dep for nonlinear dependence weights, while `(dim.red.method = "NNS.caus")` uses NNS.caus for causal weights. `(dim.red.method = "all")` averages all methods for further feature engineering. `obj.fn` expression; `expression(sum((predicted - actual)^2))` (default) Sum of squared errors is the default objective function. Any `expression()` using the specific terms `predicted` and `actual` can be used. `objective` options: ("min", "max") `"min"` (default) Select whether to minimize or maximize the objective function `obj.fn`. `status` logical; `TRUE` (default) Prints status update message in console. `ncores` integer; value specifying the number of cores to be used in the parallelized subroutine NNS.ARMA.optim. If NULL (default), the number of cores to be used is equal to the number of cores of the machine - 1. `nowcast` logical; `FALSE` (default) internal call for NNS.nowcast.

## Value

Returns the following matrices of forecasted variables:

• `"interpolated_and_extrapolated"` Returns a `data.frame` of the linear interpolated and NNS.ARMA extrapolated values to replace `NA` values in the original `variables` argument. This is required for working with variables containing different frequencies, e.g. where `NA` would be reported for intra-quarterly data when indexed with monthly periods.

• `"relevant_variables"` Returns the relevant variables from the dimension reduction step.

• `"univariate"` Returns the univariate NNS.ARMA forecasts.

• `"multivariate"` Returns the multi-variate NNS.reg forecasts.

• `"ensemble"` Returns the ensemble of both `"univariate"` and `"multivariate"` forecasts.

## Note

• `dim.red.method = "cor"` is significantly faster than the other methods, but comes at the expense of ignoring possible nonlinear relationships between lagged variables.

• Not recommended for factor variables, even after transformed to numeric. NNS.reg is better suited for factor or binary regressor extrapolation.

## Author(s)

Fred Viole, OVVO Financial Systems

## References

Viole, F. and Nawrocki, D. (2013) "Nonlinear Nonparametric Statistics: Using Partial Moments" https://www.amazon.com/dp/1490523995/ref=cm_sw_su_dp

Viole, F. (2019) "Multi-variate Time-Series Forecasting: Nonparametric Vector Autoregression Using NNS" https://www.ssrn.com/abstract=3489550

Viole, F. (2020) "NOWCASTING with NNS" https://www.ssrn.com/abstract=3586658

Viole, F. (2019) "Forecasting Using NNS" https://www.ssrn.com/abstract=3382300

Vinod, H. and Viole, F. (2017) "Nonparametric Regression Using Clusters" https://link.springer.com/article/10.1007/s10614-017-9713-5

Vinod, H. and Viole, F. (2018) "Clustering and Curve Fitting by Line Segments" https://www.preprints.org/manuscript/201801.0090/v1

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50``` ``` ## Not run: #################################################### ### Standard Nonparametric Vector Autoregression ### #################################################### set.seed(123) x <- rnorm(100) ; y <- rnorm(100) ; z <- rnorm(100) A <- cbind(x = x, y = y, z = z) ### Using lags 1:4 for each variable NNS.VAR(A, h = 12, tau = 4, status = TRUE) ### Using lag 1 for variable 1, lag 3 for variable 2 and lag 3 for variable 3 NNS.VAR(A, h = 12, tau = c(1,3,3), status = TRUE) ### Using lags c(1,2,3) for variables 1 and 3, while using lags c(4,5,6) for variable 2 NNS.VAR(A, h = 12, tau = list(c(1,2,3), c(4,5,6), c(1,2,3)), status = TRUE) ### CONFIDENCE INTERVALS FOR PREDICTIONS # Store NNS.VAR output nns_estimate <- NNS.VAR(A, h = 12, tau = 4, status = TRUE) # Create bootstrap replicates using NNS.meboot replicates <- NNS.meboot(nns_estimate\$ensemble[,1])\$replicates # Apply UPM.VaR and LPM.VaR for desired confidence interval # Tail percentage used in first argument per {LPM.VaR} and {UPM.VaR} functions upper_CIs <- apply(replicates, 1, function(g) UPM.VaR(.025, 0, g)) lower_CIs <- apply(replicates, 1, function(g) LPM.VaR(.025, 0, g)) # View results cbind(nns_estimate\$ensemble[,1], lower_CIs, upper_CIs) ######################################### ### NOWCASTING with Mixed Frequencies ### ######################################### library(Quandl) econ_variables <- Quandl(c("FRED/GDPC1", "FRED/UNRATE", "FRED/CPIAUCSL"),type = 'ts', order = "asc", collapse = "monthly", start_date="2000-01-01") ### Note the missing values that need to be imputed head(econ_variables) tail(econ_variables) NNS.VAR(econ_variables, h = 12, tau = 12, status = TRUE) ## End(Not run) ```

NNS documentation built on June 26, 2021, 1:07 a.m.