measure-of-accuracy {forecastSNSTS} | R Documentation |
Mean squared or absolute
-step ahead prediction errors
Description
The function MSPE
computes the empirical mean squared prediction
errors for a collection of -step ahead, linear predictors
(
) of observations
, where
, for two indices
and
.
The resulting array provides
with being the prediction errors
ordered by magnitude; i.e., they are such that .
The lower and upper limits of the indices are
and
.
The function
MAPE
computes the empirical mean absolute prediction
errors
with ,
and
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
P
length(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)