Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel parameters and associated units #51

Open
camrinbraun opened this issue Jun 4, 2021 · 0 comments
Open

Kernel parameters and associated units #51

camrinbraun opened this issue Jun 4, 2021 · 0 comments
Assignees

Comments

@camrinbraun
Copy link
Owner

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:

  • the muadv input to the gausskern.xx functions is a placeholder for adding advection to the kernels. This has not yet been implemented and is thus fixed at 0.
  • the first input to the gausskern.xx functions is a size parameter that is a function of the max allowed diffusion (related to migr.spd) and the grid of interest. This will be the same for the kernels for each behavior state while the sigma value used to populate the 2D gaussian distribution of the kernel is where the speed parameters actually matter

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants