LastPointVSQuantile: Compare the Last Point with the Sample Quantile

Description Usage Arguments Value See Also Examples

View source: R/LastPointVSQuantile.R

Description

This function LastPointVSQuantile is used to determine the relationship between the last observation of ts and the sample quantile calculated using the rest of the points in ts. If argument exclude is specified, elements at those designated positions are further removed from the sample quantile calculation.

Usage

1
LastPointVSQuantile(ts, exclude = NULL, probT = 0.9, direction = "pos")

Arguments

ts

A numeric vector whose

  • last value is the one will be compared with the sample quantile;

  • all but the last one are used to calculate the sample quantile.

exclude

A logical vector with length equals to length(ts)-1. It is used to remove elements at designated positions from calculating the sample quantile. By default, exclude = NULL, which means no element is excluded when calculating the sample quantile.

probT

probability threshold with values in [0, 1]. The sample quantile corresponds to this probability is calculated. Depends on the direction, if

  • direction = "pos" or direction = "neg" probT should be a numeric value;

  • direction = "both" prob should be a numeric vector of two values in [0, 1]

.

direction

Directionality of the anomalies to be deteted. Options are: 'pos', 'neg' and 'both'. Defaults to be 'pos'.

Value

returns TRUE if the last element of ts is above or below the sample quantiles, FALSE otherwise.

See Also

quantile

Examples

1
2
3
4
5
6
set.seed(1)
ts <- c(rnorm(1000), 5)
exclude <- sample(c(T, F), 1000, replace = T, prob = c(0.005, 0.995))
LastPointVSQuantile(ts, exclude, 0.95, "pos")
LastPointVSQuantile(ts, exclude, 0.95, "neg")
LastPointVSQuantile(ts, exclude, c(0.1, 0.9), "both")

jingjin1018/anetimeseries documentation built on May 19, 2019, 10:35 a.m.