Learn R Programming

verification (version 1.40)

predcomp.test: Time Series Prediction Comparison Test

Description

Forecast prediction comparison test for two competing forecasts against an observation.

Usage

predcomp.test(x, xhat1, xhat2, alternative = c("two.sided", "less", "greater"),
    lossfun = "losserr", lossfun.args = NULL,
    fitmodel = NULL, fitmodel.args = NULL, ...)

losserr(x, xhat, method = c("abserr", "sqerr", "simple", "power", "corrskill", "dtw"), scale = 1, p = 1, dtw.interr = c("abserr", "sqerr", "simple", "power"), ...)

exponentialACV(x, y, ...)

## S3 method for class 'predcomp.test': summary(object, ...)

Arguments

x,xhat1,xhat2,xhat
numeric vectors giving the verification data and each competing forecast model output (1 and 2). For losserr, xhat is a numeric giving a single forecast model output (i.e., by default the function is called internally by p
y
x for exponentialACV is a numeric giving the separation distance, and y a numeric giving the autocovariance values.
object
list object of class predcomp.test as returned by predcomp.test.
alternative
character string stating which type of hypothesis test to conduct.
lossfun
character string naming the loss function to call. The default, losserr, calls one of several methods depending on its method argument. Any function that takes x and xhat numeric vectors as arguments a
lossfun.args
List providing additional arguments to lossfun.
fitmodel
character string naming a function such as exponentialACV.

Should only be used if the method of Hering and Genton (2011) is to be employed.

This is a function for fitting a parameteric covariance to the empirical autocovariances. For examp

fitmodel.args
list object giving any additional arguments required by the function given by fitmodel.
method,dtw.interr
character string stating which type of loss (or skill) function to use. In the case of dtw.interr, this is the loss function for the intensity part of the error only.
scale
numeric giving a value by which to scale the loss function. In the case of dtw, this is only applied to the intensity part of the loss function, and can be used to scale the influence of the intensity vs. temporal lag errors
p
numeric only used by the power loss function.
...
For predcomp.test, these are any additional arguments to the acf function besides x, type and plot, which may not be passed.

For losserr, these are any additional arguments to

Value

  • predcomp.test returns a list object of class c(predcomp.test, htest) with components:
  • callthe calling string
  • methodcharacter string giving the full name of the method (Diebold-Mariano or Hering-Genton) used.
  • fitmodelcharacter naming the function used to fit the parametric model to the autocovariances or none.
  • fitmodel.argsIf fitmodel is used, then this will be a list of any arguments passed in for it.
  • loss.functioncharacter string naming the loss function called.
  • statisticnumeric giving the value of the statistic.
  • alternativecharacter string naming which type of hypothesis test was used (i.e., two-sided or one of the one-sided possibilities).
  • p.valuenumeric giving the p-value for the test.
  • data.namecharacter vector naming the verification and competing forecast series applied to the test.
  • losserr returns a numeric vector of loss values.

    exponentialACV returns a list object of class nls as returned by nls.

Details

This function performs the analyses described in Gilleland and Roux (2014). Namely, the Diebold Mariano test for competing forecast performance, the Hering and Genton (2011) modification of this test, as well as the dynamic time warping extension.

The Diebold-Mariano test was proposed in Diebold and Mariano (1995) for obtaining hypothesis tests to compare the forecast accuracy of two competing forecasts against a common verification series. The null hypothesis is that they have the same accuracy. The test statistic is of the form

S = dbar/sqrt(2*pi*se_{d}(0)/N),

where d is the loss differential, d = e1 - e2 (e1 = loss(x, xhat1) and e2 = loss(x, xhat2)), dbar is its sample mean, and se_{d}(0) is the standard error for d, which must be estimated, and N is the length of the series investigated. Let V = 2*pi*se_{d}(0), then V is estimated by

V = sum(gamma(tau)),

where the summation is over tau = -(k - 1) to (k - 1) for temporal lags k, and gamma are the empirical autocovariances.

Hering and Genton (2011) propose a modification that employs fitting a parameteric covariance model in determining the standard error for the test statistic (they also propose a spatial extension, see, e.g., spatMLD from SpatialVx). If fitmodel is not NULL, then this is the method applied, and the resulting standard error is calculating by summing up the values of this function up to half the maximum lag.

In either case, asymptotic results suggest that S ~ N(0,1), and the hypothesis test is conducted subsequently.

Discrete time warping can be applied (see examples below) in order to obtain a loss function based on location (in time) and intensity errors similar to the spatial version in Gilleland (2013).

The loss functions supplied by losserr include:

abserr: Absolute error loss, defined by abs((xhat - x)/scale),

sqerr: Square error loss, defined by ((xhat - x)/scale)^2,

simple: Simple loss, defined by (xhat - x)/scale,

power: Power loss, defined by ((xhat - x)/scale)^p (same as sqerr if p=2),

corrskill: Correlation skill defined by scale * (x - mean(x)) * (xhat - mean(xhat)),

dtw: Discrete time warp loss defined by: d1 + d2, where d1 is the absolute distance (ignoring direction) of warp movement, and d2 is one of the above loss functions (except for corrskill) applied to the resulting intensity errors after warping the series.

The exponentialACV function takes numeric vector arguments x and y and estimates the parameters, c(sigma, theta), that optimize

y = sigma^2*exp(-3*x/theta)

using nls. If fitmodel = exponentialACV, then this exponential function is fit to the data set where x are lags and y are empirical autocovariances (found by a call to acf).

References

Diebold, F. X. and Mariano, R. S. (1995) Comparing predictive accuracy. Journal of Business and Economic Statistics, 13, 253--263.

Gilleland, E. (2013) Testing competing precipitation forecasts accurately and efficiently: The spatial prediction comparison test. Mon. Wea. Rev., 141 (1), 340--355, http://dx.doi.org/10.1175/MWR-D-12-00155.1.

Gilleland, E. and Roux, G. (2014) A New Approach to Testing Forecast Predictive Accuracy. Submitted to Meteorol. Appl. Temporarily available at: http://www.ral.ucar.edu/~ericg/GillelandRoux_metapps.pdf

Hering, A. S. and Genton, M. G. (2011) Comparing spatial predictions. Technometrics, 53, (4), 414--425, doi:10.1198/TECH.2011.10136.

See Also

print.htest, nls, dtw, acf

Examples

Run this code
z0 <- arima.sim(list(order=c(2,0,0), ar=c(0.8,-0.2)), n=1000)
z1 <- c(z0[10:1000], z0[1:9]) + rnorm(1000, sd=0.5)
z2 <- arima.sim(list(order=c(3,0,1), ar=c(0.7,0,-0.1), ma=0.1), n=1000) + 
    abs(rnorm(1000, mean=1.25))

test <- predcomp.test(z0, z1, z2)
summary(test)

test2 <- predcomp.test(z0, z1, z2, fitmodel="exponentialACV")
summary(test2)

test2.2 <- predcomp.test(z0, z1, z2, alternative="less", fitmodel="exponentialACV")
summary(test2.2)

test3 <- predcomp.test(z0, z1, z2, lossfun.args=list(method="dtw"), fitmodel="exponentialACV")
summary(test3)

test3.2 <- predcomp.test(z0, z1, z2, alternative="less", lossfun.args=list(method="dtw"),
    fitmodel="exponentialACV")
summary(test3.2)

test4 <- predcomp.test(z0, z1, z2, lossfun.args=list(method="corrskill"),
    fitmodel="exponentialACV")
summary(test4)

test5 <- predcomp.test(z0, z1, z2, lossfun.args=list(method="dtw", dtw.interr="sqerr"),
    fitmodel="exponentialACV")
summary(test5)

test5.2 <- predcomp.test(z0, z1, z2, alternative="less",
    lossfun.args=list(method="dtw", dtw.interr="sqerr"), fitmodel="exponentialACV")
summary(test5.2)

Run the code above in your browser using DataLab