| measure-of-accuracy {forecastSNSTS} | R Documentation |
Mean squared or absolute h-step ahead prediction errors
Description
The function MSPE computes the empirical mean squared prediction
errors for a collection of h-step ahead, linear predictors
(h=1,\ldots,H) of observations X_{t+h}, where
m_1 \leq t+h \leq m_2, for two indices m_1 and m_2.
The resulting array provides
\frac{1}{m_{\rm lo} - m_{\rm up} + 1} \sum_{t=m_{\rm lo}}^{m_{\rm up}} R_{(t)}^2,
with R_{(t)} being the prediction errors
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)} \leq R_{(t+1)}.
The lower and upper limits of the indices are
m_{\rm lo} := m_1-h + \lfloor (m_2-m_1+1) \alpha_1 \rfloor and
m_{\rm up} := m_2-h - \lfloor (m_2-m_1+1) \alpha_2 \rfloor.
The function MAPE computes the empirical mean absolute prediction
errors
\frac{1}{m_{\rm lo} - m_{\rm up} + 1} \sum_{t=m_{\rm lo}}^{m_{\rm up}} R_{(t)},
with m_{\rm lo}, m_{\rm up} and 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 |
predcoef |
the prediction coefficients in form of a list of an array
|
m1 |
first index from the set in which the indices |
m2 |
last index from the set in which the indices |
P |
maximum order of prediction coefficients to be used;
must not be larger than |
H |
maximum lead time to be used;
must not be larger than |
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 |
trimUp |
percentage |
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)