Implementation of EARS-C1 algorithm in Julia. To run just include the function in your code:
#Setup in Julia
include("EARS_C1.jl")
and run the function over any list of cases observed at the same time step:
#Running in Julia
cases = [1,2,1,0,0,1,2,3,1,1,0,0,0,1,2,1,1,1,1,0,0,0,1,1]
detected = EARS_C1(cases, initial_date = 1)
You can also run the algorithm from R
using JuliaCall
:
#Setup in R
library(JuliaCall)
julia <- julia_setup()
julia_command('include("EARS_C1.jl")')
and then call the function:
cases <- rpois(100,20) #Simulate cases
julcases <- julia_eval("EARS_C1")(cases) #Evaluate function
The algorithm is faster than current implementation in the surveillance
package:
library(surveillance)
library(microbenchmark)
#Comparación de tiempos
mb <- microbenchmark(
cases <- rpois(100, 20),
julcases <- julia_eval("EARS_C1")(cases),
surv <- earsC(as(ts(cases, start = 1),"sts"),
control = list(method = "C1", alpha = 0.05, baseline = 7, minSigma = 0)),
times = 1000
)
With results 10 times faster:
expr | min | lq | mean | median | uq | max | neval |
---|---|---|---|---|---|---|---|
cases <- rpois(100, 20) | 12.356 | 18.329 | 24.32397 | 23.7460 | 26.8080 | 99.146 | 1000 |
julcases <- julia_eval("EARS_C1")(cases) | 425.427 | 573.103 | 766.03114 | 654.5255 | 749.8775 | 53798.048 | 1000 |
surv <- earsC(as(ts(cases, start = 1), "sts"), control = list(method = "C1", alpha = 0.05, baseline = 7, minSigma = 0)) | 4400.425 | 5103.316 | 6045.99175 | 5582.3825 | 6040.5920 | 45565.106 | 1000 |