HARforecast: HAR forecasting

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Rolling out of sample forecasting of a HAR model.

Usage

1
2
3
HARForecast(RM, BPV= NULL, RQ = NULL , periods = c(1,5,22), 
            periodsJ = NULL, periodsRQ = NULL, nRoll=10 , nAhead=1 , type = "HAR",
            windowType = "rolling", insanityFilter = TRUE, h = 1)

Arguments

RM

An xts object containing a realized measure of the integrated volatility.

BPV

A numeric containing the jump proportion of the realized measure used for HARJ and HARQ-J types.

RQ

A numeric containing the realized quarticity used for HARQ and HARQ-J types.

periods

A vector denoting which lags should be used in the estimation, standard of c(1,5,22) is in line with Corsi(2009).

periodsJ

A numeric denoting which lags should be used in Jump estimation, if applicable.

periodsRQ

A numeric denoting which lags should be used in Realized Quarticity estimation, if applicable.

nRoll

How many rolling forecasts should be performed.

nAhead

The length of each rolling forecast.

type

A character denoting which type of HAR model to estimate.

windowType

A character denoting which kind of window to use, either "rolling"/"fixed" or "increasing"/"expanding". 2-letter abbreviations can be used.

insanityFilter

A logical denoting whether the insanity filter should be used for the forecasted values see Bollerslev, Patton & Quaedvlieg(2016) footnote 17.

h

A integer denoting the whether and how much to aggregate the realized variance estimator, if h = 5 the model is forecasting the weekly volatility and if h = 22, the model is forecasting the monthly volatility, the default of 1 designates no aggregation..

Details

Not all models in this package are 'complete', which means some models use AR(1) processes to forecast e.g. realized quarticity in order to construct more than one step ahead forecasts.

The maximumm lag of the continuous or quarticity data must be lower than the maximum of the realized measure lag vector, the other cases are not implemented.

The estimates for the HARQ and HARQ-J models differ slightly from the results of BPQ (2016). This is due to a small difference in the demeaning approach for the realized quarticity. Here, the demeaning is done with mean(RQ) over all periods.

If h is greater than 1, then nAhead must be one, as multi-period ahead forecasts have not been implemented.

Value

A HARForecast object

Author(s)

Emil Sjoerup

References

Corsi, F. 2009, A Simple Approximate Long-Memory Model of Realized Volatility, Journal of Financial Econometrics, 174–196.
Bollerslev, T., Patton, A., Quaedvlieg, R. 2016, Exploiting the errors: A simple approach for improved volatility forecasting, Journal of Econometrics , vol.192 , issue 1, 1-18.

See Also

See Also HAREstimate

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
57
58
59
60
61
62
63
64
65
#HAR of Corsi(2009)
#load data:
data("SP500RM")
SP500rv = SP500RM$RV

ForecastHAR = HARForecast(SP500rv, periods = c(1,5,22), nRoll =50,
                          nAhead = 50, type = "HAR")

#plot the forecasted series along with the actual realizations:
plot(ForecastHAR)

#Calculate the MSE:
mean(forecastRes(ForecastHAR)^2)

#Calculate the Q-like loss function:
mean(qlike(ForecastHAR))




#HARJ
#load data:
data("SP500RM")
SP500rv = SP500RM$RV
SP500bpv = SP500RM$BPV


ForecastHARJ = HARForecast(SP500rv, BPV = SP500bpv, periods = c(1,5,22),
                            periodsJ = c(1,5,22) ,nRoll = 50,
                            nAhead = 50, type = "HARJ")

#Show the model:
show(ForecastHARJ)

#Extract the forecasted series:
forc = getForc(ForecastHARJ)




#HARQ BPQ(2016)
#load data
data("SP500RM")
SP500rv = SP500RM$RV
SP500rq = SP500RM$RQ

ForecastHARQ = HARForecast(SP500rv, RQ= SP500rq, periods = c(1,5,22), 
                            periodsRQ = c(1,5,22), nRoll = 50, nAhead = 50,
                            type = "HARQ")





#HARQ-J BPQ(2016) with weekly aggregation.
#load data
data("SP500RM")
SP500rv = SP500RM$RV
SP500rq = SP500RM$RQ
SP500bpv = SP500RM$BPV

ForecastHARQJ = HARForecast(SP500rv, RQ = SP500rq, BPV = SP500bpv,
                             periods = c(1,5,22), periodsJ = c(1,5,22), 
                             periodsRQ = c(1,5,22), nRoll = 50,
                             nAhead = 1, type = "HARQ-J", h = 5)

HARModel documentation built on Aug. 31, 2019, 5:05 p.m.