-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
73 lines (57 loc) · 2.15 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
output:
github_document:
html_preview: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# capacc
An `R` package for detecting (collective and point) anomalies (CAPA-CC) or changepoints (CPT-CC) in cross-correlated data.
It also contains code to reproduce the simulation study in Tveten, Eckley, Fearnhead (2020) "Scalable changepoint and anaomly detection in cross-correlated data with an application to condition monitoring".
## Overview
Functionality:
* Function for running the CAPA-CC algorithm on data, as well as CPT-CC for a single change, implemented in C++.
* Functions for visualising the detected collective and point anomalies.
* Functions for estimating a precision matrix restricted to a given adjacency matrix by the GLASSO method.
* Functions for generating test data and running the simulation study in "Scalable changepoint and anaomly detection in cross-correlated data with an application to condition monitoring".
## Installation
You can install capacc from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("Tveten/capacc")
```
## Exported and documented functions
For more information, see the documentation of the functions below inside R.
* capa.cc
* cpt.cc
* robust_sparse_precision
* plot.capacc
* simulate_cor
* car_precision_mat
The following functions rerun the simulation study:
* all_known_power_runs10
* all_known_power_runs100
* all_known_cpt_runs10
* all_known_cpt_runs100
* all_cpt_est_runs
* all_multiple_anom_runs10
* all_multiple_anom_runs100
* all_subset_est_runs
## Example
```{r example, message = FALSE, warning = FALSE}
library(capacc)
p <- 10
Sigma <- solve(car_precision_mat(lattice_neighbours(p), rho = 0.95))
x <- simulate_cor(n = 200, p = p, Sigma = Sigma)$x
Q <- robust_sparse_precision(x, adjacency_mat(banded_neighbours(2, ncol(x)), sparse = FALSE))
print(round(Q, 2))
res <- capa.cc(x, Q, b = 1, min_seg_len = 5)
plot(res)
collective_anomalies(res)
```