# NOT RUN {
# Set simulation parameters (small)
set.seed(1)
n_loc <- 20
n_dur <- 10
n_streams <- 2
n_tot <- n_loc * n_dur * n_streams
# Create locations and kNN matrix
geo <- data.frame(x = rnorm(n_loc), y = rnorm(n_loc))
knn_mat <- coords_to_knn(geo, k = 10)
# Generate baselines and possibly other distribution parameters
baselines <- rexp(n_tot, 1/5) + rexp(n_tot, 1/5)
sigma2s <- rexp(n_tot)
# Generate counts
counts <- rpois(n_tot, baselines)
# Reshape into arrays
counts <- array(counts, c(n_dur, n_loc, n_streams))
baselines <- array(baselines, c(n_dur, n_loc, n_streams))
sigma2s <- array(sigma2s, c(n_dur, n_loc, n_streams))
# Inject an outbreak/event
ob_loc <- 1:floor(n_loc / 4)
ob_dur <- 1:floor(n_dur / 4)
ob_streams <- 1:floor(n_streams / 2)
counts[ob_dur, ob_loc, ob_streams] <- 4 * counts[ob_dur, ob_loc, ob_streams]
# Run the Subset Aggregation FN algorithm
FN_res <- mscan_fss(
counts = counts,
distribution = "poisson",
algorithm = "naive_streams"
parameters = list(baselines = baselines))
# Run the FF algorithm (few random restarts)
FF_res <- mscan_fss(
counts = counts,
distribution = "gaussian",
algorithm = "fast"
parameters = list(baselines = baselines, variances = variances),
knn_matrix = knn_mat,
R = 10)
# }
Run the code above in your browser using DataLab