Title: | Fit Continuous-Time Markov Modulated Poisson Process Movement Models to Animal Resight Data |
---|---|
Description: | Using animal resight data, the package functions allow the user to estimate movement rates and resource selection using a continuous-time Markov chain movement model. |
Authors: | Devin Johnson [aut, cre] |
Maintainer: | Devin Johnson <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.0.9022 |
Built: | 2024-11-05 04:43:22 UTC |
Source: | https://github.com/dsjohnson/moveMMPP |
Define specifics for model structure and fitting control
mmpp_model(form = ~1, link = "soft_plus", a = 1, L = 0, U = 0) mmpp_control( lambda = mmpp_model(), q_r = mmpp_model(), q_m = mmpp_model(), struc = "mult", norm = TRUE )
mmpp_model(form = ~1, link = "soft_plus", a = 1, L = 0, U = 0) mmpp_control( lambda = mmpp_model(), q_r = mmpp_model(), q_m = mmpp_model(), struc = "mult", norm = TRUE )
form |
Model formula for MMPP model components, residency, movement, and detection |
link |
A link function for the model component. One of |
a |
Scale parameter for the |
L |
Lover bound for general logit link. |
U |
Upper bound for general logit link. |
lambda |
A named list for the detection portion of the model. See |
q_r |
A named list for the residency model. Must contain elements: |
q_m |
A named list for the movement portion of the model. See |
struc |
The form of the rate matrix entries. Can be one of: |
norm |
Should the movement portion be adjusted to sum to 1. This is the parameterization suggested by Hewitt et al. (2023). |
Hewitt, J., Gelfand, A. E., & Schick, R. S. (2023). Time-discretization approximation enriches continuous-time discrete-space models for animal movement. The Annals of Applied Statistics, 17:740-760.
Create sparse representations of design matrices for movement and resight models
dm_lambda(formula, ddl) dm_q_m(formula, ddl) dm_q_r(formula, ddl)
dm_lambda(formula, ddl) dm_q_m(formula, ddl) dm_q_r(formula, ddl)
formula |
An |
ddl |
Design data list |
This function is not designed for end-users but is exported for posterity.
Fit MMPP movement model to resight data
fit_mmpp( data, ddl, model_parameters = mmpp_control(), pen_fun = NULL, hessian = TRUE, start = NULL, method = "nlminb", fit = TRUE, eq_prec = 1e-08, debug = 0, ... )
fit_mmpp( data, ddl, model_parameters = mmpp_control(), pen_fun = NULL, hessian = TRUE, start = NULL, method = "nlminb", fit = TRUE, eq_prec = 1e-08, debug = 0, ... )
data |
A processed data frame produced by the function |
ddl |
A design data list produced by the function |
model_parameters |
Model formula for the detection and movement portions
of the MMPP model. See |
pen_fun |
An optional penalty function. Should be on the scale of a log-prior distribution. |
hessian |
Logical. Should the Hessian matrix be calculated to obtain the parameter variance-covariance matrix. |
start |
Optional starting values for the parameter must be a list of the
form |
method |
Optimization method. See |
fit |
Logical. Should the likelihood be optimized? |
eq_prec |
Precision of the matrix exponential approximation. |
debug |
Integer from 1-4. Opens browser() at various points in the function call. Mostly for package developers. |
... |
Additional arguments passed to the optimization function
|
Two model forms are available list(lambda=list(form=~1, offset=NULL), q=list(form=~1, offset=~log(1.num_neigh)))
. For the
q
model you must use offset=0
to not have one. If it is left off, offset=~log(1.num_neigh)))
will be used. To use the movement rate form of Hewitt et al. (2023), one must use, e.g.,
q = list(res_form = ~from_var, mov_form=~to_var, offset=...)
, where from_var
is a variable
Devin S. Johnson
Hewitt, J., Gelfand, A. E., & Schick, R. S. (2023). Time-discretization approximation enriches continuous-time discrete-space models for animal movement. The Annals of Applied Statistics, 17:740-760.
Takes fitted model and produces a summary of the beta estimates.
get_betas(par, V = NULL, data_list)
get_betas(par, V = NULL, data_list)
par |
Model estimated parameters |
V |
Optional variance-covariance matrix for the parameters. If none is given no standard errors will be provided for the real parameter estimates |
data_list |
The data list from a fitted model object |
Devin S. Johnson
Get the limiting utilization distribution of the CTMC movement process
get_lim_ud(fit = NULL, hpd = NULL, method = "lu", ...)
get_lim_ud(fit = NULL, hpd = NULL, method = "lu", ...)
fit |
A moveMMPP fitted model object from |
hpd |
A vector of probabilities. Will return columns with highest probability area for each specified probability. E.g.,
|
method |
Method used for eigen decomposition. One of |
... |
Extra arguments to pass to |
Devin S. Johnson
Get movement transition matrix from fitted moveMMP object
get_Q(fit, sparse = TRUE)
get_Q(fit, sparse = TRUE)
fit |
A moveMMPP fitted model object from |
sparse |
Logical. Should the matrix be returned in a sparse format from the |
Devin S. Johnson
Produce design data for use in fitting MMPP movement models
make_design_data( sighting_data = NULL, cell_data, rast_mask = NULL, debug = 0, ... )
make_design_data( sighting_data = NULL, cell_data, rast_mask = NULL, debug = 0, ... )
sighting_data |
—. |
cell_data |
—. |
rast_mask |
Raster mask for inaccessible cells when |
debug |
Debugging level: 1-3 mainly for package developers. |
... |
Ignored arguments. |
Create model data necessary for MMPP simulation
make_sim_dm(ddl, model_parameters = mmpp_control())
make_sim_dm(ddl, model_parameters = mmpp_control())
ddl |
Design data list created from |
model_parameters |
Model formula for the detection and movement portions of the MMPP model. |
Devin S. Johnson
Create Q and L matrices for MMPP simulation
make_sim_par(sim_dm, par)
make_sim_par(sim_dm, par)
sim_dm |
A list of design matrices resulting from a call to |
par |
A list corresponding to the coefficients for lambda, Q_m, and Q_r. It must match the
lengths in |
Evaluate movement MMPP log-likelihood
mmpp_ll(par, data_list, debug = 0, ...)
mmpp_ll(par, data_list, debug = 0, ...)
par |
Parameter vector |
data_list |
List of required data objects to evaluate likelihood |
debug |
For developers only, leave in the default setting. |
... |
Extra wiggle room for ignored arguments. |
Devin S. Johnson
Process MMPP movement detection data for model fitting
process_data(data, cell_name = NULL, aug_timestamp = NULL, time_unit = "days")
process_data(data, cell_name = NULL, aug_timestamp = NULL, time_unit = "days")
data |
Detection data. Must contain columns |
cell_name |
Character. The column name in the data representing the discrete spatial cells on which the animal moves. |
aug_timestamp |
Augmented times for modeling temporally dynamic movement or detection. See 'Details' |
time_unit |
—. |
(aug_timestamp
can be either passed as a separate vector of
POSIXct or process_data
can derive a sequence of regularly spaced
augmentation times from the original data. This is specified by providing a
character string that corresponds to the by argument of the seq.POSIXt
function (e.g. '1 year', '1 month').
Simulate a Markov Modulated Poisson Process
sim_mmpp(n = 1, max_time, min_obs, Q, L, start_loc = NULL)
sim_mmpp(n = 1, max_time, min_obs, Q, L, start_loc = NULL)
n |
Number of independent simulations |
max_time |
... |
min_obs |
... |
Q |
A movement rate matrix |
L |
A detection rate vector |
start_loc |
Starting location of the path. If not specified, the limiting distribution
implied by |
Devin S. Johnson