Function estimateL()
estimates the out-of-sample loss of a given algorithm on specified time-series. By default, it uses the optimal weighting scheme which exploits also the in-sample performance in order to deliver a more precise estimate than the conventional estimator.
estimateL(
y,
algorithm,
m,
h = 1,
v = 1,
xreg = NULL,
lossFunction = function(y, yhat) { (y - yhat)^2 },
method = "optimal",
Phi = NULL,
bw = NULL,
rhoLimit = 0.99,
...
)
Univariate time-series object.
Algorithm which is to be applied to the time-series. The object which the algorithm produces should respond to fitted
and forecast
methods.
Alternatively in the case of more complex custom algorithms, the algorithm may be a function which takes named arguments ("yInSample", "yOutSample", "h")
or ("yInSample", "yOutSample", "h", "xregInSample", "xregOutSample")
as inputs and produces a list with named elements ("yhatInSample", "yhatOutSample")
containing vectors of in-sample and out-of-sample forecasts.
Length of the window on which the algorithm should be trained.
Number of predictions made after a single training of the algorithm.
Number of periods by which the estimation window progresses forward once the predictions are generated.
Matrix of exogenous regressors supplied to the algorithm (if applicable).
Loss function used to compute contrasts (defaults to squared error).
Can be set to either "optimal"
for the estimator which optimally utilizes also the in-sample performance or "convetional"
for the conventional loss estimator.
User can also directly supply Phi
; the matrix of contrasts produced by tsACV
. In this case parameters: y
, algorithm
, m
, h
, v
, xreg
, lossFunction
are ignored.
Bandwidth for the long run variance estimator. If NULL
, bw
is selected according to (3/4)*n^(1/3)
.
Parameter rhoLimit
limits to the absolute value of the estimated rho
coefficient. This is useful as estimated values very close to 1 might cause instability.
Other parameters passed to the algorithm.
List containing loss estimate and its estimated variance along with some other auxiliary information like the matrix of contrasts Phi
and the weights used for computation.
# NOT RUN {
set.seed(1)
y <- rnorm(40)
m <- 36
h <- 1
v <- 1
estimateL(y, forecast::Arima, m = m, h = h, v = v)
# }
Run the code above in your browser using DataLab