[R] r - Forecast model

Stephen Donnelly sdonnelly758 at qub.ac.uk
Wed Oct 2 12:41:43 CEST 2013


Hi All,


I'm currently completing my MSc dissertation, using R to build a realised
volatility model using HAR.

There is a great guide on using high frequency in R which has been
invaluable to me. I was wondering though if you could all help with one
issue?

I've successfully achieved page 16 example in this pdf:
http://cran.r-project.org/web/packages/highfrequency/highfrequency.pdf

However, I would like to forecast the model into the future for a few
periods. So far I have had no success and it doesn't seem to let me forecast
harmodel like an ar model.

Do you have any suggestions? I thought it would be relatively easy to extend
the forecast that takes place in the example you already provided.

My dissertation would be grateful for any help you can offer.

Thanks very much, Stephen Donnelly

P.S:

rm(list=ls(all=TRUE))
library("highfrequency")

log.ret <- function(x) { y <- diff(log(x)); return(y) }

x <- as.matrix(read.csv("C:/users/u590799/Desktop/DATA-TEST.csv"))

dates <- x[,1]
times <- x[,2]
values <- as.numeric(x[,3])
times[which(times=="")] <- "00:00:00"

date.n.time <- matrix(NA, NROW(x), 1)
for(i in seq(1, NROW(x), 1)){date.n.time[i,1] <- paste(dates[i], times[i],
sep="     ")}
date.n.time2 <- as.Date(as.character(date.n.time), "%Y-%m-%d %H:%M:%OS")

x <- as.matrix(values); rownames(x) <- date.n.time; colnames(x)
y <- log.ret(x) #5 min log returns
y <- as.xts(y)

setwd("C:/Users/u590799/Documents/QUB/RV/Output") 

fname <- "The New Style-Settings-Normalised"
y.out <- harModel(data=y, periods = c(1,5,22),RVest = c("rCov"),
type="HARRV",h=1,     transform=NULL)
capture.output(summary(y.out),file=paste(fname, "out-summary.txt", sep="-"))
pdf(file=paste(fname, "out-plot.pdf", sep="-"), paper="a4r", width=12 ,
height=11.7); plot(y.out); dev.off()



--
View this message in context: http://r.789695.n4.nabble.com/r-Forecast-model-tp4677392.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list