hit.ratio | R Documentation |
Sometimes it is interesting to analyze just whether the forecast can predict the direction of a change in a modelled time-series. This function computes the proportion of correctly predicted signs (i.e., in which cases the direction of a change given by forecast agrees with the change in real data).
hit.ratio(y,y.hat,d=NULL)
y |
|
y.hat |
|
d |
optional, |
numeric
Baur, D. G., Beckmann, J., Czudaj, R., 2016. A melting pot – Gold price forecasts under model and parameter uncertainty. International Review of Financial Analysis 48, 282–291.
wti <- crudeoil[-1,1]
drivers <- (lag(crudeoil[,-1],k=1))[-1,]
ld.wti <- (diff(log(wti)))[-1,]
ld.drivers <- drivers[-1,]
ld.drivers[,c(4,6)] <- (diff(drivers[,c(4,6)]))[-1,]
ld.drivers[,c(1:2,5,7)] <- (diff(log(drivers[,c(1:2,5,7)])))[-1,]
ld.drivers[,c(3,6)] <- ld.drivers[,c(3,6)]/100
m1 <- fDMA(y=wti,x=drivers[,5:7],alpha=0.99,lambda=0.99,initvar=10)
hit.ratio(y=wti,y.hat=m1$y.hat)
m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.99,initvar=10)
hit.ratio(y=ld.wti,y.hat=m2$y.hat,d=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.