toad: Toad example

Description Usage Arguments Details Functions datasets (simulated and real) Author(s) References Examples

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 \insertCiteMarchand2017;textualBSL. This example includes both simulated and real data. The real data is obtained from the supplementary material of \insertCiteMarchand2017;textualBSL.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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, α, γ and p0.

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 distance-based return probability model. The default is 1.

d0

Characteristic distance for model 3. Only used if model is 3.

na

Logical. This is the index matrix for missing observations. By default, matrix(FALSE, ndays, ntoads) indicates there is no missingness in the observation matrix.

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 \insertCiteMarchand2017;textualBSL. Please see \insertCiteMarchand2017;textualBSL for a full description of the toad model, and also \insertCiteAn2018;textualBSL for Bayesian inference with the semi-BSL method.

Functions

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 θ=(1.7,35,0.6). This is the data used in \insertCiteAn2018;textualBSL. The real dataset is obtained from the supplementary data of \insertCiteMarchand2017;textualBSL.

Author(s)

Ziwen An, Leah F. South and Christopher Drovandi

References

\insertAllCited

()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## 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(detectCores() - 1)
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(detectCores() - 1)
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)

ziwenan/BSL documentation built on April 25, 2021, 1:11 p.m.