measure-of-accuracy {forecastSNSTS}R Documentation

Mean squared or absolute hh-step ahead prediction errors

Description

The function MSPE computes the empirical mean squared prediction errors for a collection of hh-step ahead, linear predictors (h=1,,Hh=1,\ldots,H) of observations Xt+hX_{t+h}, where m1t+hm2m_1 \leq t+h \leq m_2, for two indices m1m_1 and m2m_2. The resulting array provides

1mlomup+1t=mlomupR(t)2,\frac{1}{m_{\rm lo} - m_{\rm up} + 1} \sum_{t=m_{\rm lo}}^{m_{\rm up}} R_{(t)}^2,

with R(t)R_{(t)} being the prediction errors

Rt:=Xt+h(Xt,,Xtp+1)v^N,T(p,h)(t),R_t := | X_{t+h} - (X_t, \ldots, X_{t-p+1}) \hat v_{N,T}^{(p,h)}(t) |,

ordered by magnitude; i.e., they are such that R(t)R(t+1)R_{(t)} \leq R_{(t+1)}. The lower and upper limits of the indices are mlo:=m1h+(m2m1+1)α1m_{\rm lo} := m_1-h + \lfloor (m_2-m_1+1) \alpha_1 \rfloor and mup:=m2h(m2m1+1)α2m_{\rm up} := m_2-h - \lfloor (m_2-m_1+1) \alpha_2 \rfloor. The function MAPE computes the empirical mean absolute prediction errors

1mlomup+1t=mlomupR(t),\frac{1}{m_{\rm lo} - m_{\rm up} + 1} \sum_{t=m_{\rm lo}}^{m_{\rm up}} R_{(t)},

with mlom_{\rm lo}, mupm_{\rm up} and R(t)R_{(t)} defined as before.

Usage

MSPE(X, predcoef, m1 = length(X)/10, m2 = length(X), P = 1, H = 1,
  N = c(0, seq(P + 1, m1 - H + 1)), trimLo = 0, trimUp = 0)

MAPE(X, predcoef, m1 = length(X)/10, m2 = length(X), P = 1, H = 1,
  N = c(0, seq(P + 1, m1 - H + 1)), trimLo = 0, trimUp = 0)

Arguments

X

the data X1,,XTX_1, \ldots, X_T

predcoef

the prediction coefficients in form of a list of an array coef, and two integer vectors t and N. The two integer vectors provide the information for which indices tt and segment lengths NN the coefficients are to be interpreted; (m1-H):(m2-1) has to be a subset of predcoef$t. if not provided the necessary coefficients will be computed using predCoef.

m1

first index from the set in which the indices t+ht+h shall lie

m2

last index from the set in which the indices t+ht+h shall lie

P

maximum order of prediction coefficients to be used; must not be larger than dim(predcoef$coef)[1].

H

maximum lead time to be used; must not be larger than dim(predcoef$coef)[3].

N

vector with the segment sizes to be used, 0 corresponds to using 1, ..., t; has to be a subset of predcoef$N.

trimLo

percentage α1\alpha_1 of lower observations to be trimmed away

trimUp

percentage α2\alpha_2 of upper observations to be trimmed away

Value

MSPE returns an object of type MSPE that has mspe, an array of size H×\timesP×\timeslength(N), as an attribute, as well as the parameters N, m1, m2, P, and H. MAPE analogously returns an object of type MAPE that has mape and the same parameters as attributes.

Examples

T <- 1000
X <- rnorm(T)
P <- 5
H <- 1
m <- 20
Nmin <- 20
pcoef <- predCoef(X, P, H, (T - m - H + 1):T, c(0, seq(Nmin, T - m - H, 1)))

mspe <- MSPE(X, pcoef, 991, 1000, 3, 1, c(0, Nmin:(T-m-H)))

plot(mspe, vr = 1, Nmin = Nmin)

[Package forecastSNSTS version 1.3-0 Index]