# Three response shapes, several stimulation groups per shape.
# \donttest{
set.seed(1)
n_time <- 300L
tt <- seq(-0.2, 1, length.out = n_time)
shapes <- list(
exp(-((tt - 0.08) / 0.03)^2) - 0.5 * exp(-((tt - 0.18) / 0.04)^2),
exp(-((tt - 0.38) / 0.03)^2) - 0.5 * exp(-((tt - 0.50) / 0.04)^2),
exp(-((tt - 0.70) / 0.04)^2)
)
# 3 stimulation groups per shape, 12 trials each
V <- NULL
groups <- NULL
g <- 0L
for (s in seq_along(shapes)) {
for (rep in seq_len(3L)) {
g <- g + 1L
trials <- outer(shapes[[s]], runif(12L, 0.5, 1.5)) +
matrix(rnorm(n_time * 12L, sd = 0.2), n_time, 12L)
V <- cbind(V, trials)
groups <- c(groups, rep(g, 12L))
}
}
res <- bpc(V, groups, time = tt, time_window = c(0, 1), verbose = TRUE)
res$n_bpc
res$clusters
plot(res)
# }
Run the code above in your browser using DataLab