testL {ACV} | R Documentation |
Test equality of out-of-sample losses of two algorithms
Description
Function testL()
tests the null hypothesis of equal predictive ability of algorithm1
and algorithm2
on time series y
. By default, it uses the optimal weighting scheme which exploits also the in-sample performance in order to deliver more power than the conventional tests.
Usage
testL(
y,
algorithm1,
algorithm2,
m,
h = 1,
v = 1,
xreg = NULL,
lossFunction = function(y, yhat) { (y - yhat)^2 },
method = "optimal",
test = "Diebold-Mariano",
Ha = "!=0",
Phi = NULL,
bw = NULL,
groups = 2,
rhoLimit = 0.99,
...
)
Arguments
y |
Univariate time-series object. |
algorithm1 |
First algorithm which is to be applied to the time-series. The object which the algorithm produces should respond to |
algorithm2 |
Second algorithm. See above. |
m |
Length of the window on which the algorithm should be trained. |
h |
Number of predictions made after a single training of the algorithm. |
v |
Number of periods by which the estimation window progresses forward once the predictions are generated. |
xreg |
Matrix of exogenous regressors supplied to the algorithm (if applicable). |
lossFunction |
Loss function used to compute contrasts (defaults to squared error). |
method |
Can be set to either |
test |
Type of the test which is to be executed. Can attain values |
Ha |
Alternative hypothesis. Can attain values |
Phi |
User can also directly supply |
bw |
Applicable to |
groups |
Applicable to |
rhoLimit |
Parameter |
... |
Other parameters passed to algorithms. |
Value
List containing loss differential estimate and associated p-value along with some other auxiliary information like the matrix of contrasts differentials Phi
and the weights used for computation.
Examples
set.seed(1)
y <- rnorm(40)
m <- 36
h <- 1
v <- 1
algorithm1 <- function(y) {
forecast::Arima(y, order = c(1, 0, 0))
}
algorithm2 <- function(y) {
forecast::Arima(y, order = c(2, 0, 0))
}
testL(y, algorithm1, algorithm2, m = m, h = h, v = v)