Learn R Programming

onlineforecast (version 0.9.3)

score: Calculate the score for each horizon.

Description

Calculates the score for each horizon for a matrix with residuals for each horizon.

Usage

score(Residuals, scoreperiod = NA, usecomplete = TRUE, scorefun = rmse)

Arguments

Residuals

A matrix with residuals (columns named hxx) for which to calculate the score for each horizon.

scoreperiod

as a logical vector controlling which points to be included in the score calculation. If NA then all values are included.

usecomplete

if TRUE then only the values available for all horizons are included (i.e. if at one time point there is a missing value, then values for this time point is removed for all horizons in the calculation).

scorefun

The score function.

Value

A list with the a numeric vector with the score value for each horizon and the applied scoreperiod (note can be different from the given scoreperiod, if only complete observations are used (as per default)).

Details

Applies the scorefun on all horizons (each column) of the residuals matrix. See the description of each parameter for more details.

Examples

Run this code
# NOT RUN {
# Just a vector to be forecasted
y <- c(filter(rnorm(100), 0.95, "recursive"))
# Generate a forecast matrix with a simple persistence model
Yhat <- persistence(y, kseq=1:4)
# The residuals for each horizon
Resid <- residuals(Yhat, y)

# Calculate the score for the k1 horizon
score(Resid)$scoreval

# The first values were excluded, since there are NAs
head(Resid)
score(Resid)$scoreperiod

# }

Run the code above in your browser using DataLab