| Title: | (Animal) Movement Persistence Mixed-Effects Models |
|---|---|
| Description: | Fit covariates as linear mixed-effects to latent, time-varying movement persistence (autocorrelation). |
| Authors: | Ian Jonsen [aut, cre], Marie Auger-Méthé [aut, ctb] |
| Maintainer: | Ian Jonsen <[email protected]> |
| License: | AGPL-3 |
| Version: | 0.2-3 |
| Built: | 2026-05-10 08:32:20 UTC |
| Source: | https://github.com/ianjonsen/mpmm |
fit movement persistence mixed-effects models to animal location data
Ian Jonsen
Jonsen ID, McMahon CR, Patterson TA, et al. (2019) Movement responses to environment: fast inference of variation among southern elephant seals with a mixed effects model. Ecology. 100(1):e02566 https://doi.org/10.1002/ecy.2566
mpmm
perform likelihood ratio tests on 2 or more mpmm fit objects
## S3 method for class 'mpmm' anova(object, ...)## S3 method for class 'mpmm' anova(object, ...)
object |
an mpmm fit object |
... |
additional mpmm fit objects |
Example elephant seal Argos tracking data with environmental covariates. Data were sourced from the Integrated Marine Observing System (IMOS) - IMOS is supported by the Australian Government through the National Collaborative Research Infrastructure Strategy and the Super Science Initiative.
.RData
Example elephant seal Argos tracking data with environmental covariates. Data were sourced from the Integrated Marine Observing System (IMOS) - IMOS is supported by the Australian Government through the National Collaborative Research Infrastructure Strategy and the Super Science Initiative.
.RData
mpmm
inner_control allows specification of control parameters for the
inner optimization used by mpmm
inner_control(...)inner_control(...)
... |
control parameters for the inner optimizer |
See MakeADFun and newton
for details and available options. Adapted from S. Wotherspoon
https://github.com/SWotherspoon/RWalc/blob/master/R/RWalc.R
Returns a list with components:
control |
list of control parameters for inner optimizer |
fit <- mpmm(~ ice + (ice | id), data = ellie.ice.short, inner.control = inner_control(tol = 1e-03))fit <- mpmm(~ ice + (ice | id), data = ellie.ice.short, inner.control = inner_control(tol = 1e-03))
extract log-likelihood from an mpmm fit object
## S3 method for class 'mpmm' logLik(object, ...)## S3 method for class 'mpmm' logLik(object, ...)
object |
an mpmm model fit object |
... |
additional arguments to be ignored |
Fit a move persistence random walk via TMB to a pre-filtered/regularized animal track and estimate gamma as a linear function of covariates
mpmm( formula = NA, data = NULL, map = NULL, control = mpmm_control(), inner.control = inner_control() )mpmm( formula = NA, data = NULL, map = NULL, control = mpmm_control(), inner.control = inner_control() )
formula |
a right-hand-side regression formula (no response variable) |
data |
a data frame of observations (see details) |
map |
a named list of parameters as factors that are to be fixed during estimation, e.g., list(rho = factor(NA)) |
control |
a list of control parameters for the outer optimization
(see |
inner.control |
a list of control parameters for the inner optimization
(see |
The input track is given as a dataframe where each row is an observed location and columns
individual animal identifier,
observation time (POSIXct,GMT),
observed longitude,
observed latitude,
identifier for tracks if there are more than one track per individual (optional),
named covariates appended to track
a list with components
states |
a dataframe of estimated states |
fitted |
a dataframe of fitted locations |
par |
model parameter summmary |
data |
input dataframe |
tmb |
the tmb object |
opt |
the object returned by the optimizer |
data(ellie.ice.short) fit <- mpmm(~ ice + (1 | id), data = ellie.ice.short) summary(fit)data(ellie.ice.short) fit <- mpmm(~ ice + (1 | id), data = ellie.ice.short) summary(fit)
mpmm.mpmm_control selects the numerical minimizer, method, associated
control parameters, parameter bounds, and likelihood estimation (REML or ML)
used by mpmm.
mpmm_control( optim = c("nlminb", "optim"), method = c("BFGS", "L-BFGS-B"), lower = NULL, upper = NULL, REML = FALSE, profile = FALSE, verbose = 2, ... )mpmm_control( optim = c("nlminb", "optim"), method = c("BFGS", "L-BFGS-B"), lower = NULL, upper = NULL, REML = FALSE, profile = FALSE, verbose = 2, ... )
optim |
the numerical optimizer used in the fit |
method |
optimization method to be used - one of "BFGS" or "L-BFGS-B"
for bounded optimization (default |
lower |
a list of named parameter lower bounds, if NULL then built in
defaults are used when |
upper |
a list of named parameter upper bounds, if NULL then built in
defaults are used when |
REML |
logical; whether to use REML (TRUE) or maximum likelihood |
profile |
logical; option to improve speed and convergence by using REML parameter estimates as initial values for ML optimization |
verbose |
integer; report progress during minimization: 0 = silent; 1 = optimizer trace; 2 = parameter trace (default)) |
... |
control parameters for the chosen optimizer |
The optimizer used to minimize the objective function is
selected by the optim argument. Additional control
parameters specific to the chosen optimizer are specified via the
dots argument. See nlminb and optim
for available options. Adapted from S. Wotherspoon
https://github.com/SWotherspoon/RWalc/blob/master/R/RWalc.R
Returns a list with components
optim |
the name of the numerical optimizer as a string, "nlminb" or "optim" |
method |
optimization method to be used |
lower |
named list of lower parameter bounds |
upper |
named list of upper parameter bounds |
REML |
whether REML is to be used in place of ML |
profile |
whether to enhance convergence robustness |
verbose |
level of tracing information to be reported |
control |
list of control parameters for the optimizer |
fit <- mpmm(~ ice + (ice | id), data = ellie.ice.short, control = mpmm_control( optim = "nlminb", REML = FALSE, eval.max = 2000) )fit <- mpmm(~ ice + (ice | id), data = ellie.ice.short, control = mpmm_control( optim = "nlminb", REML = FALSE, eval.max = 2000) )
Visualise fixed and random covariate relationships from an mpmm fit object
## S3 method for class 'mpmm' plot(x, label = FALSE, lwd = c(0.25, 0.75), ...)## S3 method for class 'mpmm' plot(x, label = FALSE, lwd = c(0.25, 0.75), ...)
x |
an mpmm fit object |
label |
add id labels to random effects |
lwd |
a vector of regression line widths (random effect, fixed effects) |
... |
additional arguments to be ignored |
Extract one-step-ahead residuals
## S3 method for class 'mpmm' residuals( object, method = "oneStepGaussianOffMode", trace = FALSE, parallel = TRUE, ncores = detectCores() - 1, ... )## S3 method for class 'mpmm' residuals( object, method = "oneStepGaussianOffMode", trace = FALSE, parallel = TRUE, ncores = detectCores() - 1, ... )
object |
an mpmm fit object |
method |
character naming the method to calculate one-step-ahead residuals |
trace |
logical; print progress to console |
parallel |
logical; compute in parallel |
ncores |
integer; number of cores to use (default = total cores detected - 1) |
... |
additional arguments to be ignored |
Wrapper function for modified oneStepPredict
that calculates one-step-ahead residuals, which are residuals that account
for temporal correlation in latent states. The modification allows easier
parallel computation.
a list with components
res |
a tibble with one-step-ahead residuals for longitude and latitude |
Thygesen, U. H., C. M. Albertsen, C. W. Berg, K. Kristensen, and A. Neilsen. 2017. Validation of ecological state space models using the Laplace approximation. Environmental and Ecological Statistics 24:317–339.
## Not run: data(ellie.ice) fit <- mpmm(~ ice + (1 | id), data = ellie.ice) summary(fit) residuals(fit) ## End(Not run)## Not run: data(ellie.ice) fit <- mpmm(~ ice + (1 | id), data = ellie.ice) summary(fit) residuals(fit) ## End(Not run)
return a summary of an mpmm fit object
## S3 method for class 'mpmm' summary(object, ...)## S3 method for class 'mpmm' summary(object, ...)
object |
an mpmm fit object |
... |
additional arguments to be ignored |