Description Usage Arguments Examples
View source: R/dsdive.gibbs.obs.cov.R
This function differs from dsdive.gibbs.obs
in that this function
allows the model to be estimated with dive-specific covariates.
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 | dsdive.gibbs.obs.cov(
dsobs.list,
covs,
t.stages.list,
beta.init,
alpha.init,
verbose = FALSE,
maxit,
checkpoint.fn,
checkpoint.interval = 3600,
beta1.prior,
beta2.prior,
alpha1.prior,
alpha2.prior,
alpha3.prior,
tstep,
depth.bins,
T1.prior.params,
T2.prior.params,
max.width,
max.width.offset,
t0.prior.params,
tf.prior.params,
offsets,
offsets.tf,
cl,
pi.formula,
lambda.formula,
warmup = Inf,
delta = 1e-10,
optim.maxit = 1000,
adaptive = FALSE,
adaptation.frequency = 10,
gapprox = TRUE
)
|
dsobs.list |
list of |
covs |
matrix of covariates associated with |
t.stages.list |
list of initial stage transition times for dives
observed in |
beta.init |
Initial values for directional preference model parameters.
See |
alpha.init |
Initial values for diving rate model parameters. See
|
verbose |
|
maxit |
number of Gibbs iterations to run |
checkpoint.fn |
User-defined function to run during a checkpoint step; gives the user an opportunity to save partial output from the sampler |
checkpoint.interval |
Number of seconds between calls to
|
beta1.prior |
List containing |
beta2.prior |
List containing |
alpha1.prior |
List containing |
alpha2.prior |
List containing |
alpha3.prior |
List containing |
tstep |
Time between observations in |
depth.bins |
n x 2 Matrix that defines the depth bins. The first column defines the depth at the center of each depth bin, and the second column defines the half-width of each bin. |
T1.prior.params |
|
T2.prior.params |
|
max.width |
The stage transition times are updated with a piecewise
proposal distribution. |
max.width.offset |
The t0 and tf offsets are updated with a piecewise
proposal distribution. |
t0.prior.params |
|
tf.prior.params |
|
offsets |
vector with initial values for t0 offsets. |
offsets.tf |
vector with initial values for tf offsets. |
cl |
Shared-memory cluster to be used to distribute some computations.
The cluster must be fully initialized before running this function.
The cluster requires random seeds and |
pi.formula |
List of formula objects, each of which defines the linear
model that combines covariates in the |
lambda.formula |
List of formula objects, each of which defines the
linear model that combines covariates in the |
warmup |
number of iterations during which the proposal distributions will be updated at each step |
delta |
If |
optim.maxit |
maximum number of steps to take during numerical optimization to compute Gaussian approximation to full conditional posteriors used to propose model parameters |
adaptive |
|
adaptation.frequency |
Random walk proposals will only be updated at intervals of this step count |
gapprox |
If |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | data('dive.sim')
attach(dive.sim)
attach(dive.sim$params)
library(parallel)
library(Rdsm)
cl = makeCluster(2, 'SOCK')
clusterEvalQ(cl, library(dsdive))
clusterEvalQ(cl, library(Rdsm))
mgrinit(cl)
t.stages = sim$times[c(FALSE,diff(sim$stages)==1)]
tstep = diff(sim.obs$times[1:2])
obstx.mat = lapply(1:3, function(s) {
dsdive.obstx.matrix(depth.bins = depth.bins, beta = beta,
lambda = lambda, s0 = s, tstep = tstep,
include.raw = TRUE, delta = 1e-10)
})
lambda.priors = list(
list(mu = 0, sd = 3),
list(mu = 0, sd = 3),
list(mu = 0, sd = 3)
)
beta.priors = list(
list(mu = 0, sd = 3),
list(mu = 0, sd = 3)
)
T1.prior.params = c(25, .04)
T2.prior.params = c(56, .06)
dsobs.list = list(sim.obs, sim.obs)
t.stages.list = list(t.stages, t.stages)
beta.init = list(
c(qlogis(.5), 0),
c(0, 1)
)
alpha.init = c(beta.init, list(c(-1,-1)))
covs = data.frame(x1 = c(.5, 1), x2 = c(0, .3))
pi.formula = ~x1
lambda.formula = ~x1:x2
fit = dsdive.gibbs.obs.cov(
dsobs.list = dsobs.list, t.stages.list = t.stages.list,
beta.init = beta.init, alpha.init = alpha.init, verbose = TRUE, maxit = 1,
beta1.prior = beta.priors[[1]], beta2.prior = beta.priors[[2]],
alpha1.prior = lambda.priors[[1]], alpha2.prior = lambda.priors[[2]],
alpha3.prior = lambda.priors[[3]], tstep = tstep, depth.bins = depth.bins,
T1.prior.params = T1.prior.params, T2.prior.params = T2.prior.params,
max.width = 100, max.width.offset = 30, t0.prior.params = c(1,1),
tf.prior.params = c(1,1), offsets = 0, offsets.tf = 0, warmup = 1,
covs = covs, pi.formula = pi.formula, lambda.formula = lambda.formula,
cl = cl, optim.maxit = 1, delta = 1e-10)
detach(dive.sim$params)
detach(dive.sim)
stopCluster(cl)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.