# NOT RUN {
# pls() function now works correctly only when varVec is provided
# And varVec is not provided by any function, but is generated inside them.
# Generate data, apply es() with the holdout parameter and calculate PLS
x <- rnorm(100,0,1)
ourModel <- es(x, h=10, holdout=TRUE, intervals=TRUE)
sigma <- t(ourModel$errors) %*% (ourModel$errors) / length(ourModel$residuals)
Etype <- substr(modelType(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', intervals=TRUE)
Etype <- substr(modelType(ourModel),1,1)
iprob <- ourModel$imodel$fitted
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