runMCMC: Run MCMC iterations

View source: R/runMCMC.R

runMCMCR Documentation

Run MCMC iterations

Description

Run MCMC iterations

Usage

runMCMC(
  track,
  nbStates,
  nbIter,
  burnin,
  inits,
  fixed,
  priors,
  props,
  tunes,
  Hmat,
  updateState = TRUE,
  adapt = FALSE,
  model = NA
)

Arguments

track

data.frame. Data, with columns x, y, time, and ID

nbStates

integer. Number of states

nbIter

integer. Number of iterations for the MCMC

inits

list. Initial parameters:

  • tau_pos: vector. Initial tau_{pos} for each state, of length nbStates

  • tau_vel: vector. Initial tau_{vel} for each state, of length nbStates

  • sigma: vector. Initial sigma for each state, of length nbStates for isotropic covariance or 3 * nbStates for anisotropic covariance

  • mu: list. Initial OUF range centre coordinate pairs ⁠(x, y)⁠, with NA for IOU states

  • Q:

  • state: vector. Initial state sequence, length nrow(track)

  • rateparam: vector. Length dependent on model choice

fixed

list of fixed parameters:

  • tau_pos: vector. Fixed values of tau_{pos} for each state with NA for parameters to estimate. Length nbStates

  • tau_vel: vector. Fixed values of tau_{vel} for each state with NA for parameters to estimate. Length nbStates

  • sigma: vector. Fixed values of sigma for each state with NA for parameters to estimate. Length nbStates for isotropic covariance, or 3 * nbStates for anisotropic covariance

  • mu: list. Fixed OUF range centre coordinate pairs ⁠(x, y)⁠, with NA for IOU states or pairs to estimate

  • Q: Unused

  • knownStates: vector. Known states with NA for those to estimate. Length nrow(track)

  • kappa: integer. Maximum transition rate to bound rates when they are modelled. Length 1

priors

list. Parameters of prior distributions, with components:

  • func: list of distribution function names, of length 5 * nbStates or 7 * nbStates for movement parameters + length(rateparam) when estimating rate parameters rateparam by MH

  • args: list of list containg function args for distribution functions, of length 5 * nbStates or 7 * nbStates for movement parameters + length(rateparam) when estimating rate parameters rateparam by MH

  • shape: vector. Shapes of gamma priors for the transition rates when Gibbs sampling

  • rate: vector. Rates of gamma priors for the transition rates when Gibbs sampling

  • con: vector. Concentrations of Dirichlet priors for transition probabilities when Gibbs sampling

props

list. Parameters of proposal distributions, with components:

  • S: matrix. Initial value for the lower triangular matrix of RAM algorithm, so that the covariance matrix of the proposal distribution is ⁠SS'⁠. Dimensions ⁠(5 * nbStates, 5 * nbStates)⁠ when not modelling rate parameters (model is NA) and ⁠(5 * nbStates + length(rateparam), 5 * nbStates + length(rateparam))⁠ otherwise.

  • updateLim: vector. Two values: min and max length of updated state sequence

  • updateProbs: vector. Probabilities for each element of updateLim[1]:updateLim[2] (if NULL, all values are equiprobable)

tunes

list. Tuning parameters, with components:

  • thinStates: integer. Thinning factor for the posterior state sequences (needed because of memory limitations)

Hmat

matrix. Observation error variance (four columns, and one row for each row of data)

updateState

logical. If FALSE, the state process is not updated (for exploratory analysis only, useful for testing single state models)

adapt

integer. If adapt > 0, use the the Robust Adaptive Metropolis (RAM) algorithm by Vihola (2012) to update the proposal distribution for each parameter at each iteration (up to adapt iterations) to a target acceptance rate of 23.4%.

model

experimental

References

Michelot, T., Blackwell, P.G. (2019). State‐switching continuous‐time correlated random walks. Methods Ecol Evol, 10: 637-649. doi:10.1111/2041-210X.13154

Vihola, M. (2012). Robust adaptive Metropolis algorithm with coerced acceptance rate. Stat Comput, 22: 997-1008. doi:10.1007/s11222-011-9269-5


dylanirion/MSctmm documentation built on Sept. 27, 2024, 3:41 a.m.