Skip to contents

Cost functions for the Least Absolution Deviation from a given quantile

Details

this is a very niaive and slow implimentation

Methods


Method length()

Get the length of time series

Usage

ladCost$length()


Method new()

Initialise the cost function

Usage

ladCost$new(x, m = 0, tau = 0.5)

Arguments

x

numeric vector of observations

m

expected value of x

tau

the quantile


Method baseCost()

Compute the non-anomalous cost of a segment

Usage

ladCost$baseCost(a, b, pen = 0)

Arguments

a

start of period

b

end of period

pen

penalty cost


Method pointCost()

Compute the point anomaly cost of a time step

Usage

ladCost$pointCost(a, pen)

Arguments

a

time step

pen

penalty cost


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

ladCost$collectiveCost(a, b, pen, len)

Arguments

a

start of period

b

end of period

pen

penalty cost

len

minimum number of observations


Method param()

Compute parameters of a segment if anomalous

Usage

ladCost$param(a, b)

Arguments

a

start of period

b

end of period


Method clone()

The objects of this class are cloneable with this method.

Usage

ladCost$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

set.seed(0)
m <- runif(100)
x <- rnorm(100,m)

p <- ladCost$new(x,m,0.5)
p$baseCost(90,95) ## cost of non-anomalous distribution for x[90:95]
#> [1] -12.48888
p$pointCost(90,0) ## point anomaly cost for x[90] with 0 penalty
#> [1] -2.772589
## collective anomaly cost for x[90:95] with penalty of 57 and at least 3 observation
p$collectiveCost(90,95,57,3)
#> [1] 43.86362