find_bestanalogue_time: Finds the time index of the best analogue of rank association

Description Usage Arguments Value Examples

View source: R/r2d2_algo.R

Description

Finds the time index of the best analogue of block_conddim_BC in conddim_REF in terms of the Euclidean distance.

Usage

1
find_bestanalogue_time(conddim_REF, block_conddim_BC)

Arguments

conddim_REF

A matrix of dimension T_ref x P_cond that contains the rank data where the best analogue of block_conddim_BC is searched. T_ref is the number of time steps and P_cond is the number of conditioning dimensions.

block_conddim_BC

A matrix of dimension T_block x P_cond. It corresponds to the block of rank association for which the best analogue is searched in conddim_REF. T_block corresponds to a number of time steps in the block (i.e., its length) and should be lower or equal to T_ref.

Value

A list with the following elements:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
refdata <- matrix(c(0.3, 0.5, 0.9, 0.8,
                    1.1, 1.7, 1.2, 1.9,
                    2.1, 1.8, 3.0, 2.7), ncol = 3, nrow = 4)
bc1d <- matrix(c(0.7, 0.5, 0.2, 0.9,
                 1.3, 1.8, 1.1, 1.4,
                 1.9, 2.9, 2.0, 2.6), ncol = 3, nrow = 4)

ranks_refdata <- apply(refdata, 2, rank)
ranks_bc1d <- apply(bc1d, 2, rank)

# 1 conditioning dimension, 0 lag
icond <- 1
block_conddim_BC <- ranks_bc1d[1, icond, drop = FALSE]
conddim_REF <- ranks_refdata[, icond, drop = FALSE]
find_bestanalogue_time(conddim_REF, block_conddim_BC)

# 1 conditioning dimension, 1 lag
icond <- 1
block_conddim_BC <- ranks_bc1d[1:2, icond, drop = FALSE]
conddim_REF <- ranks_refdata[, icond, drop = FALSE]
find_bestanalogue_time(conddim_REF, block_conddim_BC)

# 2 conditioning dimensions, 1 lag
icond <- 1:2
block_conddim_BC <- ranks_bc1d[1:2, icond, drop = FALSE]
conddim_REF <- ranks_refdata[, icond, drop = FALSE]
find_bestanalogue_time(conddim_REF, block_conddim_BC)

thaos/R2D2 documentation built on Sept. 14, 2020, 9:01 p.m.