compute_rrmse: Compute RRMSE in a time series estimate

Description Usage Arguments Value Examples

View source: R/compute_rrmse.R

Description

compute_rrmse() computes the relative root mean square error (RRMSE) in a time series estimate of a known time-varying quantity.

Usage

1
compute_rrmse(x, y, na_rm = TRUE)

Arguments

x

Numeric vector. A time series.

y

Numeric vector with length equal to length(x). A time series estimate of x.

na_rm

Logical. If TRUE, then missing values (NA, NaN, Inf) are ignored.

Value

Let cc ("complete cases") be the vector of indices i such that neither x[i] nor y[i] is missing. If length(cc) = 0 or if length(cc) < length(x) and na_rm = FALSE, then NA. Otherwise, the RRMSE in y given by sqrt(sum((x[cc] - y[cc])^2) / length(cc)) / mean(x[cc]).

Examples

1
2
3
x <- rep(c(0, 1, 0, -1), 100)
y <- x + rnorm(x, 0, 0.01)
compute_rrmse(x, y) # RRMSE in `y`

davidearn/fastbeta documentation built on June 14, 2020, 3:11 p.m.