toad {BSL}  R Documentation 
Toad example
Description
This example estimates the parameter for the toad example. The model simulates the movement of an amphibian called Fowler's toad. The model is proposed by Marchand et al. (2017). This example includes both simulated and real data. The real data is obtained from the supplementary material of Marchand et al. (2017). The journal article An et al. (2022) provides a full description of how to use this package for the toad example.
Usage
data(toad)
toad_sim(
theta,
ntoads,
ndays,
model = 1,
d0 = 100,
na = matrix(FALSE, ndays, ntoads)
)
toad_sum(X, lag = c(1, 2, 4, 8), p = seq(0, 1, 0.1))
toad_prior(theta)
Arguments
theta 
A vector of proposed model parameters,

ntoads 
The number of toads to simulate in the observation. 
ndays 
The number of days observed. 
model 
Which model to be used: 1 for the random return model, 2 for the nearest return model, and 3 for the distancebased return probability model. The default is 1. 
d0 
Characteristic distance for model 3. Only used if 
na 
Logical. This is the index matrix for missing observations. By
default, 
X 
The data matrix. 
lag 
The lag of days to compute the summary statistics, default as 1, 2, 4 and 8. 
p 
The numeric vector of probabilities to compute the quantiles. 
Details
The example includes the three different returning models of Marchand et al. (2017). Please see Marchand et al. (2017) for a full description of the toad model, and also An et al. (2019) for Bayesian inference with the semiBSL method.
Functions

toad_sim
: Simulates data from the model, using C++ in the backend. 
toad_sum
: Computes the summary statistics for this example. The summary statistics are the log differences between adjacent quantiles and also the median. 
toad_prior
: Evaluates the log prior at the chosen parameters.
datasets (simulated and real)
A simulated dataset and a real dataset are provided in this example. Both
datasets contain observations from 66 toads for 63 days. The simulated
dataset is simulated with parameter
\theta = (1.7, 35,
0.6)
. This is the data used in An et al. (2019). The real
dataset is obtained from the supplementary data of
Marchand et al. (2017).

data_simulated
: A 63\times
66 matrix of the observed toad locations (simulated data). 
data_real
: A 63\times
66 matrix of the observed toad locations (real data). 
cov
: The covariance matrix of a multivariate normal random walk proposal distribution used in the MCMC, in the form of a 3\times
3 matrix. 
theta0
: A vector of suitable initial values of the parameters for MCMC. 
sim_args_simulated
andsim_args_real
: A list of the arguments to pass into the simulation function.
ndays
: The number of days observed. 
ntoads
: The total number of toads being observed. 
model
: Indicator of which model to be used. 
na
: Indicator matrix for missingness.

Author(s)
Ziwen An, Leah F. South and Christopher Drovandi
References
An Z, Nott DJ, Drovandi C (2019).
“Robust Bayesian Synthetic Likelihood via a SemiParametric Approach.”
Statistics and Computing (In Press).
An Z, South LF, Drovandi CC (2022).
“BSL: An R Package for Efficient Parameter Estimation for SimulationBased Models via Bayesian Synthetic Likelihood.”
Journal of Statistical Software, 101(11), 1–33.
doi: 10.18637/jss.v101.i11.
Marchand P, Boenke M, Green DM (2017).
“A stochastic movement model reproduces patterns of site fidelity and longdistance dispersal in a population of Fowlers toads (Anaxyrus fowleri).”
Ecological Modelling, 360, 63–69.
ISSN 03043800, doi: 10.1016/j.ecolmodel.2017.06.025.()
Examples
## Not run:
require(doParallel) # You can use a different package to set up the parallel backend
data(toad)
## run standard BSL for the simulated dataset
model1 < newModel(fnSim = toad_sim, fnSum = toad_sum, theta0 = toad$theta0,
fnLogPrior = toad_prior, simArgs = toad$sim_args_simulated,
thetaNames = expression(alpha,gamma,p[0]))
paraBound < matrix(c(1,2,0,100,0,0.9), 3, 2, byrow = TRUE)
# Performing BSL (reduce the number of iterations M if desired)
# Opening up the parallel pools using doParallel
cl < makeCluster(min(detectCores()  1,2))
registerDoParallel(cl)
resultToadSimulated < bsl(toad$data_simulated, n = 1000, M = 10000, model = model1,
covRandWalk = toad$cov, logitTransformBound = paraBound,
parallel = TRUE, verbose = 1L, plotOnTheFly = 100)
stopCluster(cl)
registerDoSEQ()
show(resultToadSimulated)
summary(resultToadSimulated)
plot(resultToadSimulated, thetaTrue = toad$theta0, thin = 20)
## run standard BSL for the real dataset
model2 < newModel(fnSim = toad_sim, fnSum = toad_sum, theta0 = toad$theta0,
fnLogPrior = toad_prior, simArgs = toad$sim_args_real,
thetaNames = expression(alpha,gamma,p[0]))
paraBound < matrix(c(1,2,0,100,0,0.9), 3, 2, byrow = TRUE)
# Performing BSL (reduce the number of iterations M if desired)
# Opening up the parallel pools using doParallel
cl < makeCluster(min(detectCores()  1,2))
registerDoParallel(cl)
resultToadReal < bsl(toad$data_real, n = 1000, M = 10000, model = model2,
covRandWalk = toad$cov, logitTransformBound = paraBound,
parallel = TRUE, verbose = 1L, plotOnTheFly = 100)
stopCluster(cl)
registerDoSEQ()
show(resultToadReal)
summary(resultToadReal)
plot(resultToadReal, thetaTrue = toad$theta0, thin = 20)
## End(Not run)