| 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 |
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 |
weights |
numeric vector where first value represents weight for |
Value
numeric matrix of similarities which is calculated using S_w.
See Also
Trupiano (2021) arXiv:2112.06266 for information on the formulation of
S_w.-
StMatrixCalc()for information on the calculation ofS_t. -
SpMatrixCalc()for information on the calculation ofS_p. -
SxMatrixCalc()for information on the calculation ofS_x.
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)
)