garch_multivariate_reg: General Interface for Multivariate GARCH Models

Description Usage Arguments Details Value Engine Details See Also Examples

View source: R/parsnip-garch_multivariate_reg.R

Description

garch_multivariate_reg() allows you to model the volatility of various time series. This can be done with the multivariate equivalent of the univariate GARCH model. Estimating multivariate GARCH models turns out to be significantly more difficult than univariate GARCH models, but this function facilitates the task through different engines such as rugarch, dcc_rmgarch, gogar_rmgarch etc.

Usage

1
garch_multivariate_reg(mode = "regression", type = NULL)

Arguments

mode

A single character string for the type of model (Only regression is supported).

type

A single character string for the type of model or specification (See details below).

Other options and argument can be set using set_engine() (See Engine Details below).

Details

Available engines:

Value

A model specfication

Engine Details

rugarch (default)

The engine uses rugarch::multispec() and then rugarch::multifit()

Main Arguments

You must pass an argument through set_engine() called specs which will be a list consisting of the arguments to be passed to each of the specifications used in rugarch::multispec(). Other arguments that you wish to pass to rugarch::multifit() can also be passed through set_engine()

For example, imagine you have a data frame with 3 variables. For each of those variables you must define a specification (you can check the arguments you can use for a specification in ?rugarch::ugarchspec). Once the specifications have been decided, the way to pass it through set_engine would be as follows:

garch_multivariate_reg(mode = "regression") %>% set_engine("rugarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))), spec2 = list(mean.model = list(armaOrder = c(1,0))), spec3 = list(mean.model = list(armaOrder = c(1,0)))), out.sample = 10)

In the fit section we will see how to pass variables through parsnip::fit (See Fit Section below).

Parameter Notes:

dcc_rmgarch

The engine uses rugarch::multispec(), rugarch::multifit(), rmgarch::dccspec() and rmgarch::dccfit().

Main Arguments

You must pass an argument through set_engine() called specs which will be a list consisting of the arguments to be passed to each of the specifications used in rugarch::multispec(). Other arguments that you wish to pass to rugarch::multifit() can also be passed through set_engine(). To pass arguments to dccfit() you must pass a list through set_engine called dcc_specs.

For example, imagine you have a data frame with 3 variables. For each of those variables you must define a specification (you can check the arguments you can use for a specification in ?rugarch::ugarchspec). Once the specifications have been decided, the way to pass it through set_engine would be as follows:

garch_fit_model <- garch_multivariate_reg(type = "ugarchspec") %>% set_engine("dcc_rmgarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))), spec2 = list(mean.model = list(armaOrder = c(1,0))), spec3 = list(mean.model = list(armaOrder = c(1,0)))), dcc_specs = list(dccOrder = c(2,2), distribution = "mvlaplace"))

In the fit section we will see how to pass variables through parsnip::fit (See Fit Section below).

c_rmgarch

The engine uses rugarch::multispec(), rugarch::multifit(), rmgarch::cgarchspec() and rmgarch::cgarchfit().

Main Arguments

You must pass an argument through set_engine() called specs which will be a list consisting of the arguments to be passed to each of the specifications used in rugarch::multispec(). Other arguments that you wish to pass to rugarch::multifit() can also be passed through set_engine(). To pass arguments to cgarchfit() you must pass a list through set_engine called c_specs.

For example, imagine you have a data frame with 3 variables. For each of those variables you must define a specification (you can check the arguments you can use for a specification in ?rugarch::ugarchspec). Once the specifications have been decided, the way to pass it through set_engine would be as follows:

garch_fit_model <- garch_multivariate_reg(type = "arfima") %>% set_engine("c_rmgarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))), spec2 = list(mean.model = list(armaOrder = c(1,0))), spec3 = list(mean.model = list(armaOrder = c(1,0)))), c_specs = list(dccOrder = c(2,2))) %>% fit(value ~ date + id, data = rX_longer_train)

In the fit section we will see how to pass variables through parsnip::fit (See Fit Section below).

gogarch_rmgarch

The engine uses rmgarch::gogarchspec() and rmgarch::gogarchfit().

Main Arguments

You must pass an argument through set_engine() called gogarch_specs which will be a list consisting of the arguments to be passed to each of the specifications used in rmgarch::gogarchspec(). Other arguments that you wish to pass to rmgarch::gogarchfit() can also be passed through set_engine().

For example, imagine you have a data frame with 3 variables. For each of those variables you must define a specification (you can check the arguments you can use for a specification in ?rugarch::ugarchspec). Once the specifications have been decided, the way to pass it through set_engine would be as follows:

model_fit_garch <- garch_multivariate_reg(type = "ugarchspec") %>% set_engine("gogarch_rmgarch" , gogarch_specs = list(variance.model = list(garchOrder = c(2,2)))) %>% fit(value ~ date + id, data = rX_longer_train)

In the fit section we will see how to pass variables through parsnip::fit (See Fit Section below).

See Also

fit.model_spec(), set_engine()

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
51
52
53
54
55
56
library(tidymodels)
library(garchmodels)
library(modeltime)
library(tidyverse)
library(timetk)
library(lubridate)

rX_longer <-  rX_longer %>%
    dplyr::mutate(date = as.Date(date)) %>%
    group_by(id) %>%
    future_frame(.length_out = 3, .bind_data = TRUE) %>%
    ungroup()

rX_longer_train  <- rX_longer %>% drop_na()
rX_longer_future <- rX_longer %>% filter(is.na(value))

#RUGARCH ENGINE

model_fit_garch <- garch_multivariate_reg() %>%
    set_engine("rugarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))), 
                                        spec2 = list(mean.model = list(armaOrder = c(1,0))),
                                        spec3 = list(mean.model = list(armaOrder = c(1,0))))) %>%
    fit(value ~ date + id, data = rX_longer_train)

predict(model_fit_garch, new_data = rX_longer_future)


#DCC ENGINE

 model_fit_garch <- garch_multivariate_reg(type = "ugarchspec") %>%
set_engine("dcc_rmgarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))), 
                                        spec2 = list(mean.model = list(armaOrder = c(1,0))),
                                        spec3 = list(mean.model = list(armaOrder = c(1,0)))),
           dcc_specs = list(dccOrder = c(2,2), distribution = "mvlaplace")) %>%
    fit(value ~ date + id, data = rX_longer_train)

predict(model_fit_garch, rX_longer_future) 


# COPULA ENGINE

model_fit_garch <- garch_multivariate_reg(type = "ugarchspec") %>%
set_engine("c_rmgarch" , specs = list(spec1 = list(mean.model = list(armaOrder = c(1,0))),
                                      spec2 = list(mean.model = list(armaOrder = c(1,0))),
                                      spec3 = list(mean.model = list(armaOrder = c(1,0)))),
           c_specs = list(dccOrder = c(2,2))) %>%
    fit(value ~ date + id, data = rX_longer_train)


# GO-GARCH ENGINE

model_fit_garch <- garch_multivariate_reg(type = "ugarchspec") %>%
set_engine("gogarch_rmgarch" , gogarch_specs = list(variance.model = list(garchOrder = c(2,2)))) %>%
    fit(value ~ date + id, data = rX_longer_train)
    
predict(model_fit_garch, rX_longer_future)

garchmodels documentation built on April 13, 2021, 1:05 a.m.