HARRV.direct.forecast: Compute the direct forecasts for the HAR-RV model.

View source: R/HARRV_direct_forecast.R

HARRV.direct.forecastR Documentation

Compute the direct forecasts for the HAR-RV model.

Description

This function computes the direct forecasts for the HAR-RV model

Usage

HARRV.direct.forecast(
  dat,
  periods = c(1, 5, 22),
  type = "HAR",
  transform = NULL,
  roll.window = 1621,
  lag_fore = 1
)

Arguments

dat

is a xts object containing intraday 5-minute regularly spaces prices (see example below)

periods

is a vector of integers indicating over how days the realized measures in the model should be aggregated. By default periods = c(1,5,22). It is needed for the computation of the HARmodel of the highfrequency package

type

is a string referring to the type of HAR model you would like to estimate using HARmodel. By default type = "HAR".

transform

optionally a string referring to a function that transforms both the dependent and explanatory variables in the HARmodel. By default transform=NULL, so no transformation is done. Typical other choices in this context would be "log" or "sqrt".

roll.window

is the rolling window size used for estimating the HAR-RV model

lag_fore

is the desired forecasting horizon. Default is 1 (that is, 1-step-ahead direct forecasts)

Details

This function computes the direct forecasts for the HAR-RV model. The benefits of direct forecasts are described in Chevillon (2007, 2016).

Value

roll.fore a xts object containing the h-day-ahead RV forecasts and the realized RV forecasts.

References

Chevillon, G. (2007). Direct multi-step estimation and forecasting. Journal of Economic Surveys,21(4),746-785.

Chevillon, G. (2016). Multistep forecasting in the presence of location shifts. International Journal of Forecasting, 32(1), 121-137.

Examples

## Not run: 
aa <-bitcoincharts_single_download(name = "bitstampUSD.csv.gz", save_data=TRUE)
data_clean<-aggregate_merge_bictoincharts_data(data_list=list(aa=aa), aggregate_every = 5)
dat<-data_clean$price_ts
dat<- dat["2013-01-02/2017-07-12"]
bb<-HARRV.direct.forecast(dat=dat)
tail(bb)
 #                     predicted     realized
 # 2017-07-07 23:55:00 0.003320551 0.0008078943
 # 2017-07-08 23:55:00 0.002369109 0.0010431969
 # 2017-07-09 23:55:00 0.002488993 0.0008631436
 # 2017-07-10 23:55:00 0.002373416 0.0021875888
 # 2017-07-11 23:55:00 0.003152035 0.0039407938
 # 2017-07-12 23:55:00 0.004210418 0.0025053951

## End(Not run)

deanfantazzini/bitcoinFinance documentation built on June 12, 2024, 4:10 p.m.