[R] Writing HAR-RV-CJ Model?

cursethiscure caolan.harvey6 at mail.dcu.ie
Thu Jul 12 18:19:34 CEST 2012

I am trying to write a loop to forecast realized volatility over successive
days for the purpose of VaR prediction using the HAR-RV-CJ model which is as

    log(RV_t+1) = β_0 + β_CD log(CV_t) + β_CW log(CV_t-5) + β_CM
log(CV_t-22) + β_JD log(J_t) + β_JW J_t-5 + β_JM J_t-22 + e_t

where RV is realized volatility, CV is continuous volatility and J is the
jump which is RV - CV, _t is subscript for time t, which is one day

basically I know how to compute ex post CV and J, and RV and have done in
another loop but need to forecast for half of my sample data to compare to
ex-post estimates of RV.

 but I don't know  how to compute the weekly and monthly estimates _t-5 and
weekly continouos volatility is given as:

    log(CV_t-5) = 1/5 * ∑ _i=1 to 5 log(C_t-i)
and similar for monthly CV and weekly and Monthly J
which I think is:

    cw = apply(embed((log(cv)), 5), 1, sum, na.rm=T) 
    cw = 1/5*(cw)
correct me if I am wrong please. 

I think also the daily lagged CV is:

    lcv = cv[-length(cv)]

Now if I can get the lagged variables correct, how do I run the above
regression so it loops over each successive day?

thanks, If i am missing any vital info please advise me. thanks

I should add say I want to loop over T days one day at a time.

 I have data for those T days but I need to compare my forecast with the
ex-post realized volatility.


View this message in context: http://r.789695.n4.nabble.com/Writing-HAR-RV-CJ-Model-tp4636320.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list