| altf | R Documentation |
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a few selected forecast methods (which might be treated as alternative ones to Dynamic Model Averaging, Dynamic Model Selection, etc.).
Naive forecast (naive) is computed in a way that all forecasts are set to be the value of the last observation.
For rolling OLS forecast (roll. OLS) for the first periods (until the size of a window is obtained) are estimated through recursive OLS (rec. OLS).
Autoregressive models (AR(1) and AR(2)) are computed by ordinary least squares method.
Time-varying parameters models (TVP, TVP-AR(1) and TVP-AR(2)) are computed as tvp with V=1 and lambda=0.99.
Auto ARIMA (auto ARIMA) is computed as auto.arima.
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy. HR (Hit Ratio) is computed as hit.ratio.
altf(y,x,window=NULL,initial.period=NULL,d=NULL,f=NULL,fmod=NULL,c=NULL)
y |
|
x |
|
window |
optional, |
initial.period |
optional, |
d |
optional, |
f |
optional, |
fmod |
optional, class |
c |
optional, |
class altf object, list of
$summary |
|
$y.hat |
|
$y |
|
$coeff. |
|
$p.val. |
|
plot.altf, print.altf, summary.altf, rec.reg, roll.reg, altf2, altf3, altf4.
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
a1 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60)
# models where constant term is not included in modelled equations (if applicable)
a2 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,c=FALSE,initial.period=60)
# compute just selected models
fcomp <- c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)
a3 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60)
m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10)
a4 <- altf(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.