score {onlineforecast} | R Documentation |
Calculate the score for each horizon.
Description
Calculates the score for each horizon for a matrix with residuals for each horizon.
Usage
score(object, scoreperiod = NA, usecomplete = TRUE, scorefun = rmse, ...)
## S3 method for class 'list'
score(object, scoreperiod = NA, usecomplete = TRUE, scorefun = rmse, ...)
## S3 method for class 'data.frame'
score(object, scoreperiod = NA, usecomplete = TRUE, scorefun = rmse, ...)
Arguments
object |
??list or A matrix with residuals (columns named |
scoreperiod |
as a logical vector controlling which points to be included in the score calculation. If NA then all values are included (depeding on 'complete'). |
usecomplete |
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. |
... |
is passed on to the score function. |
Details
Applies the scorefun
on all horizons (each column) of the residuals matrix. See the description of each parameter for more details.
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)).
Examples
# 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)
# In the beginning the horizons have NAs
head(Resid)
# Default is that only complete cases over all horizons are included
score(Resid)
# So including all cases for each horizon will give different values
score(Resid, usecomplete=FALSE)
# Given a list
# The residuals for each horizon
Resid2 <- residuals(persistence(y,kseq=1:4)+rnorm(100), y)
score(list(Resid,Resid2))