similarityMatrix: ADEPT Similarity Matrix Computation

Description Usage Arguments Value See Also Examples

View source: R/similarityMatrix.R

Description

Compute ADEPT similarity matrix between a time-series x and a collection of scaled templates.

Usage

1
similarityMatrix(x, template.scaled, similarity.measure)

Arguments

x

A numeric vector. A time-series x.

template.scaled

A list of lists of numeric vectors, as returned by scaleTemplate. Each element of template.scaled is a list of templates interpolated to a particular vector length. Number of elements in the template.scaled corresponds to the number of unique template length values used in segmentation.

similarity.measure

A character scalar. Statistic used in similarity matrix computation; one of the following:

  • "cov" - for covariance,

  • "cor" - for correlation.

Value

A numeric matrix. Contains values of similarity between a time-series x and scaled templates.

See Also

scaleTemplate {adept}

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
## Simulate data
par(mfrow = c(1,1))
x0 <- sin(seq(0, 2 * pi * 100, length.out = 10000))
x  <- x0 + rnorm(1000, sd = 0.1)
template <- list(x0[1:500])
template.vl <- seq(300, 700, by = 50)

## Rescale pattern
template.scaled <- scaleTemplate(template, template.vl)

## Compute ADEPT similarity matrix
out <- similarityMatrix(x, template.scaled, "cov")

## Visualize
par(mfrow = c(1,1))
image(t(out),
      main = "ADEPT similarity matrix\nfor time-series x and scaled versions of pattern templates",
      xlab = "Time index",
      ylab = "Pattern vector length",
      xaxt = "n", yaxt = "n")
xaxis <- c(1, seq(1000, length(x0), by = 1000))
yaxis <- template.vl
axis(1, at = xaxis/max(xaxis), labels = xaxis)
axis(2, at = (yaxis - min(yaxis))/(max(yaxis) - min(yaxis)), labels = yaxis)

oslerinhealth/adept documentation built on Oct. 10, 2019, 4:57 a.m.