Main data simulation function
## Loading required package: DrBats
## Loading required package: rstan
## Loading required package: StanHeaders
##
## rstan version 2.32.7 (Stan version 2.32.2)
## For execution on a local, multicore CPU with excess RAM we recommend calling
## options(mc.cores = parallel::detectCores()).
## To avoid recompilation of unchanged Stan programs, we recommend calling
## rstan_options(auto_write = TRUE)
## For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
## change `threads_per_chain` option:
## rstan_options(threads_per_chain = 1)
st_data <- drbats.simul(N = 10,
t.range = c(0, 1000),
b.range = c(0.2, 0.4),
c.range = c(0.6, 0.8),
b.sd = 0.5,
c.sd = 0.5,
y.range = c(-5, 5),
sigma2 = 0.2,
breaks = 15,
data.type = 'sparse.tend')mycol<-c("#ee204d", "#1f75fe", "#1cac78", "#ff7538", "#b4674d", "#926eae",
"#fce883", "#000000", "#78dbe2", "#6e5160", "#ff43a4")The parameters b.range and c.range dictate
the location of two peaks, and b.sd and c.sd
the variance of the peaks. Once the signals have been simulated, the
function samples observation times over the range of possible times
t.range. Few times are chosen in b.range and
c.range, and many are chosen outside these ranges.
The parameter data.type specifies the type of signal to
simulate: sparse will simulate a bi-modal signal that is
flat between the modes. The sparse.tend option will
simulate bi-modal signals with a trend, and the
sparse.tend.cos will simulate periodic bi-modal signals
with a trend.
matplot(t(st_data$t), t(st_data$X), type = 'l', lty = 1, lwd = 1,
xlab = 'Time', ylab = ' ', col = mycol[1:10])
points(t(st_data$t), t(st_data$X), pch = '.')