Learn R Programming

flatness (version 0.1.4)

rkhist: Return the rank histogram of an observation in an ensemble forecast

Description

This S3 generic function is intended to compute the rank of each observation when pooled with its associated ensemble forecast and return the count in each rank (i.e. the rank histogram).

Usage

rkhist(fcst, obs, ...)

Arguments

fcst

an object containing the ensemble forecasts.

obs

an object containing the observation associated to the forecast in fcst.

...

additional arguments.

Value

An S3 object of class rkhist (indeed a matrix containing the count for each rank, with class "rkhist"). Each row of the matrix contains the counts for one rank histogram.

Details

For new methods, the output should be an object of class c("rkhist", "matrix"), with one rank histogram in each row. Rows may be named.

Examples

Run this code
# NOT RUN {
set.seed(42)
N <- 1000
M <- 20
fcst <- matrix(rnorm(N*M), ncol = M)
fcst2 <- matrix(rnorm(N*M), ncol = M)
obs <- rnorm(N)
## Computation of one rank histogram
# Named
rkh <- rkhist(fcst, obs, names = "a")
print(rkh)
plot(rkh)
# Unnamed
rkh2 <- rkhist(fcst2, obs)
print(rkh2)
plot(rkh2)

## Computation of two rank histograms, from a list of forecasts, with the
## same observation vector
fcstsl <- list(fcst, fcst2)
rkhsl <- rkhist(fcstsl, obs, names = c("a", NA))
print(rkhsl)
plot(rkhsl)

## Concatenation of two rank histograms, with different names
rkhs <- rbind_rkhists(rkh, rkh2, names = letters[3:4])
rownames(rkhs)
print(rkhs)
plot(rkhs)
# }

Run the code above in your browser using DataLab