# Generate data, apply es() with the holdout parameter and calculate PLS
x <- rnorm(100,0,1)
ourModel <- es(x, h=10, holdout=TRUE)
sigma <- t(ourModel$errors) %*% (ourModel$errors) / length(ourModel$residuals)
Etype <- substr(model.type(ourModel),1,1)
pls(actuals=ourModel$holdout, forecasts=ourModel$forecast, Etype=Etype,
sigma=sigma, trace=TRUE)
# Do the same with intermittent data. Trace is not available yet for
# intermittent state-space models
x <- rpois(100,0.4)
ourModel <- es(x, h=10, holdout=TRUE, intermittent='a')
Etype <- substr(model.type(ourModel),1,1)
iprob <- window(ourModel$iprob,start(ourModel$holdout))
pls(actuals=ourModel$holdout, forecasts=ourModel$forecast, Etype=Etype,
sigma=ourModel$s2, trace=FALSE, iprob=iprob)
Run the code above in your browser using DataLab