camrinbraun / HMMoce

hidden markov model for psat data v.1.1
Other
6 stars 7 forks source link

Kernel parameters and associated units #51

Open camrinbraun opened 3 years ago

camrinbraun commented 3 years ago

The old approach

Historically in HMMoce we used fixed migratory and resident "speeds" (i.e. allowable diffusion) and an expectation-maximization algorithm to do parameter estimation for the behavior state switching. The EM algorithm was implemented in a function called makePar() (link) which is no longer part of the package but is retained in git version control for posterity. For our purposes, the important part of this workflow is how movement "speeds" were treated.

makePar took a numeric migr.spd input (in m/s) and the working model grid and pushed these to a function called calc.param() (link) which converted the user defined migratory speed (migr.spd in m/s) to the appropriate grid units (lines 20-21) and assigned a residency speed that was some fraction of the migratory (default was 10%). The result was a set of movement parameters that were then used to populate the gaussian kernel (with gausskern() link) which was used to do the convolution in hmm.filter() and hmm.smoother().

For an example implementation of this deprecated approach see an example run script for a thresher shark dataset from the Red Sea (line ~252).

The new approach

More recently, @paulgatti worked to implement full parameter estimation for both diffusion/movement speed parameters and behavior switching probabilities. This functionality is now wrapped in opt.params() (link) which uses any number of optimization routines (there are several options, such as optim and nlminb) to do parameter estimation by minimizing the negative log-likelihood. For simplicity, this approach is all based on the parameters being in grid units, thus the output "speed" parameters need to be converted if they're going to be intuitive as a speed parameter (such as in m/s). @marosteg has been working on an implementation of HMMoce where these intuitive speed parameters are needed and is working to implement this conversion.

For an example implementation of the new approach see an example run script for an albacore dataset in the N Pacific (line ~252).

To do

There are a number of complexities in dealing with these movement kernels, including, for example, the isotropic (or lack thereof) nature of the desired kernels. Thus, we have experimented with a number of different gausskern.xx functions that currently live in the -dev branch. All are working but we have yet to do systematic testing to better understand the pros/cons of each approach. Regardless of how the gaussian kernal is populated, it will be difficult to directly (and precisely) convert these grid units to a more intuitive metric; however, an approximate conversion can be implemented after the filter and smoother steps so that the parameters can be reported in a meaningful way.

Couple things to note:

If we assume a couple movement parameters (drawn from the albacore example and rounded for simplicity) of sigma1 = 3 and sigma2 = 0.3 (resid is 10% of migr) and a size parameter of 13 on a 0.25 degree grid:

K1 <- gausskern(13, 3)
K2 <- gausskern(13, 0.3)

We get (using fields::image.plot):

Screen Shot 2021-06-04 at 9 18 38 AM Screen Shot 2021-06-04 at 9 18 51 AM