Skip to contents

Cost functions for differening types of univariate gaussion anomalies

Details

Collective anomalies are represented either as changes in parameters describing the mean (gaussRegMean), variance (gaussRegVar) or mean and variance (gaussRegMeanVar). Changes in variance are represented as a scaling parameter, not changes to the covariance. See vignettes for details.

Each element of the input x should be a list containing a vector of observations y and corresponding design matrix X. Optionally in can also include a vector of parameter m and covariance matrix S.

Methods


Method length()

Get the length of time series

Usage

gaussRegCost$length()


Method new()

Initialise the cost function

Usage

gaussRegCost$new(x, non_neg = FALSE)

Arguments

x

a list of regressions (see details)

non_neg

should only non-negative paraemter solutions be considered


Method baseCost()

Compute the non-anomalous cost of a segment

Usage

gaussRegCost$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

gaussRegCost$pointCost(b, pen)

Arguments

b

time step

pen

penalty cost


Method clone()

The objects of this class are cloneable with this method.

Usage

gaussRegCost$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussRegCost -> gaussRegMean

Methods

Inherited methods


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

gaussRegMean$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

gaussRegMean$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

gaussRegMean$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussRegCost -> gaussRegVar

Methods

Inherited methods


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

gaussRegVar$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

gaussRegVar$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

gaussRegVar$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussRegCost -> gaussRegMeanVar

Methods

Inherited methods


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

gaussRegMeanVar$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

gaussRegMeanVar$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

gaussRegMeanVar$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

## simple test
set.seed(10)
x <- list()
n <- 120
for(ii in 1:48){
    
    if(ii < 10){ theta = c(1,0); sigma <- 0.1 }
    if(ii >= 10 & ii <12){ theta <- c(10,0); sigma <- 2}
    if(ii >= 12 & ii < 44){ theta <- c(5,1); sigma <- 2}
    if(ii >= 44 ){ theta <- c(1,0); sigma <- 0.1}
    
    X <- cbind(rep(1,n),runif(n,ii-1,ii))
    y <- rnorm(n, X%*%theta, sigma)
    x[[ii]] <- list(y=y,X=X)
}

fCost <- gaussRegMeanVar$new(x)
p <- partition(4*log(sum(sapply(y,length))),NA,2)
res <- pelt(p,fCost)