Learn R Programming

HMMoce (version 1.0.0)

expmax: Expectation-maximization framework for state-switching

Description

expmax performs expectation-maximization for state switching probability

Usage

expmax(p.init, g, L, K1, K2, niter = 1000, threshold = 0.01, save = F)

Arguments

p.init

a vector of length 2. The first is the probability of staying in behavior state 1 if currently in state 1 and the second for staying in state 2.

g

grid from setup.grid

L

final likelihood

K1

first movement (diffusion) kernel see gausskern

K2

second movement (diffusion) kernel see gausskern

niter

is integer that determines number of iterations to perform

threshold

is threshold of percent change that we consider satisfactory for convergence. Default is 1%.

save

is logical indicating whether the function should save and return a 2 col dataframe of the iterations it went through before crossing the convergence threshold. Defaults to not saving.

Value

a 2x2 matrix of state switching probabilities. See P.init input for more information.

Details

Light errors are parameterized using elliptical error values output in.

References

Woillez M, Fablet R, Ngo TT, et al. (2016) A HMM-based model to geolocate pelagic fish from high-resolution individual temperature and depth histories: European sea bass as a case study. Ecol Modell 321:10-22.

Examples

Run this code
# NOT RUN {
# GENERATE MOVEMENT KERNELS. D VALUES ARE MEAN AND SD PIXELS
K1 <- gausskern(3, 1, muadv = 0)
K2 <- gausskern(10, 5, muadv = 0)

# MAKE A GUESS AT STATE SWITCHING PROBABILITY
# probability of staying in state 1 and 2, respectively
p.init <- c(0.7, 0.8)

# }
# NOT RUN {
# Not run as it relies on L, a large likelihood grid
# RUN EXPECTATION-MAXIMIZATION ROUTINE FOR MATRIX, P (STATE SWITCH PROBABILITY)
P.final <- expmax(p.init, g = g, L = L, K1, K2)

# }

Run the code above in your browser using DataLab