# NOT RUN {
library(anomaly)
### generate some multivariate data
set.seed(2018)
x1 = rnorm(500)
x2 = rnorm(500)
x3 = rnorm(500)
x4 = rnorm(500)
### Add two (lagged) collective anomalies
x1[151:200] = x1[151:200]+2
x2[171:200] = x2[171:200]+2
x3[161:190] = x3[161:190]-3
x1[351:390] = x1[371:390]+2
x3[351:400] = x3[351:400]-3
x4[371:400] = x4[371:400]+2
### Add point anomalies
x4[451] = x4[451]*max(1,abs(1/x4[451]))*5
x4[100] = x4[100]*max(1,abs(1/x4[100]))*5
x2[050] = x2[050]*max(1,abs(1/x2[050]))*5
my_x = cbind(x1,x2,x3,x4)
### Now apply MVCAPA
res<-scapa.mv(my_x,max_lag=20,type="mean")
### Examine the output at different times and see how the results are updated:
plot(res,epoch=155)
plot(res,epoch=170)
plot(res,epoch=210)
# }
Run the code above in your browser using DataLab