clst_plot: Cluster Visualization

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/clst_plot.R

Description

This function plots a list of returns of hypo_test.

Usage

1
2
clst_plot(x, org_x = x, clst, alpha_lvl, unit,
          x_range = c(min(org_x), max(org_x)), plt_mgn = 0)

Arguments

x

A numeric vector of data values where is hypothesis test is applied on.

org_x

A numeric vector of original data values. Default is x, means scan statistics hypothesis test is applied on all the observations.

clst

A list of matrices. Each matrix has three columns where the first column is clusters starting indexes, second column is the corresponding clusters ending indexes and the third column is the corresponding significant level for clusters.

alpha_lvl

Maximum alpha level in legend.

unit

A number indicating bin width for histogram in the plot.

x_range

xlim for plot

plt_mgn

extra margin of clusters shown in plot.

Details

If ggplot2 is installed, the plot is done via ggplot. If not, the plot is done via basic R plot.

Number of layers in the plot is determined by number of elements in clst. alpha_lvl must be equal or larger than the maximum significant level of clusters in the plot.

x and org_x are not necessary to be the same. Within some specific scenarios where we do not want to detect clusters among all observations, we can apply hypo_test only on cdf that are converted by x. Please be awared the each component in clst must come from the detected results of x.

plt_mgn is for small clusters that can barely be seen in plot. This happens when the magnitude of cluster is too small as sample size quit large.

Value

This function returns a plot. If ggplot installed, it returns an object as ggplot. If not, it returns an object as recordedplot

Author(s)

Zhicong Zhao

See Also

hypo_test for detected clusters and prob_fun for q-values of corresponding clusters.

Examples

1
2
3
4
5
6
## generate data
x <- qnorm(seq(0,1,0.001))
x <- x[-c(1,length(x))]
x <- c(x[1:100],rep(x[100],10),x[101:length(x)])
clst <- lapply(1:10,function(x)matrix(c(100,110,0.01*x),nrow = 1))
clst_plot(x = x, clst = clst, alpha_lvl = 0.1, unit = 0.1, plt_mgn = 0.1)

zhicongz/AnomDetct documentation built on Dec. 12, 2019, 9:16 a.m.