SwMatrixCalc {knnwtsim}R Documentation

Calculate Weighted Similarity Matrix

Description

A wrapper function which calls each of StMatrixCalc(v = t.in), SpMatrixCalc(v = p.in, nPeriods = nPeriods.in), and SxMatrixCalc(A = X.in, XdistMetric = XdistMetric.in) to generate the three matrices of using the component measures of S_w. Then generates the final weighted similarity matrix as the sum of each component matrix multiplied by its corresponding weights. The first value in weights will be multiplied by S_t, the second S_p, and the third S_x.

Usage

SwMatrixCalc(
  t.in,
  p.in,
  nPeriods.in,
  X.in,
  XdistMetric.in = "euclidean",
  weights = c(1/3, 1/3, 1/3)
)

Arguments

t.in

numeric vector of time orders for points in the response series.

p.in

numeric vector of period within a seasonal cycle (ex. 1 for January points in monthly data).

nPeriods.in

numeric scalar indicating the maximum value p.in could take on (ex. 12 for monthly data).

X.in

numeric vector or matrix of exogenous predictors, where the rows correspond to points in the response series.

XdistMetric.in

character describing the method stats::dist() should use. This must be one of "euclidean", "maximum", "manhattan", "canberra", "binary", or "minkowski".

weights

numeric vector where first value represents weight for S_t, second value the weight for S_p, and the third value the weight for S_x.

Value

numeric matrix of similarities which is calculated using S_w.

See Also

Examples

t <- c(1, 2, 3)
p <- c(1, 2, 1)
X <- matrix(c(1, 1, 1, 2, 2, 2, 3, 3, 3), nrow = 3, ncol = 3, byrow = TRUE)
SwMatrixCalc(
  t.in = t,
  p.in = p, nPeriods.in = 2,
  X.in = X,
  weights = c(1 / 4, 1 / 4, 1 / 2)
)

[Package knnwtsim version 1.0.0 Index]