-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
71 lines (51 loc) · 3.46 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
message = FALSE
)
```
**mpmm** - fit movement persistence mixed-effects models to animal tracking data
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
master branch:
[![R-CMD-check](https://github.com/ianjonsen/mpmm/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ianjonsen/mpmm/actions/workflows/R-CMD-check.yaml)
dev branch:
[![R-CMD-check](https://github.com/ianjonsen/mpmm/actions/workflows/R-CMD-check.yaml/badge.svg?branch=dev)](https://github.com/ianjonsen/mpmm/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
`mpmm` is an R package that fits movement persistence mixed-effect models to animal tracking data for inference of linear relationships with covariates, accounting for individual variability (Jonsen et al. 2019. Ecology 100:e02566). Random effects are assumed to be approximately normal. It is assumed that the location data are either relatively error-free (e.g., GPS locations) or filtered estimates from a state-space model fitted to error-prone data (e.g., Argos locations). Models are specified using standard mixed-model formulas, as you would in `lme4` or `glmmTMB`. The movement persistence model can be fit as either a discrete-time (Jonsen et al. 2019) or a continuous-time (Auger-Méthé et al. 2017. MEPS 565:237-249) process. The underlying code for specifying and estimating fixed and random effects borrows heavily on `glmmTMB` code, but is implemented in a more limited manner in `mpmm`. Currently, only diagonal or unstructured covariances are possible; interaction terms are not possible; the grouping term for the random effects is always assumed to be the individual animal `id` (or individual sub-tracks `tid`).
## Installation
First, ensure you have R version >= 3.6.0 installed (preferably R 4.0.0 or higher):
```{r get-version, eval = FALSE}
R.Version()
```
### From GitHub (source)
On PC's running Windows, ensure you have installed [Rtools](https://cran.r-project.org/bin/windows/Rtools/)
On Mac's, ensure you have installed the [Command Line Tools for Xcode](https://developer.apple.com/download/more/) by executing `xcode-select --install` in the terminal; or you can download the latest version from the URL (free developer registration may be required). A full Xcode install uses up a lot of disk space and is not required.
Currently, `mpmm` can only be installed from GitHub:
```{r gh-installation, eval = FALSE}
remotes::install_github("ianjonsen/mpmm")
```
Note: there can be issues getting compilers to work properly, especially on a Mac with OS X 10.13.x or higher. If you encounter install and compile issues, I recommend you consult the excellent information on the [glmmTMB](https://github.com/glmmTMB/glmmTMB) GitHub.
## Basic example
`mpmm` fits mixed models and facilitates model selection, validation and visualisation of estimated covariate relationships:
```{r example, warning=FALSE, message=FALSE, fig.width=8, fig.height=6}
library(mpmm)
fit <-
mpmm(
~ ice + sal_diff + (ice |
id),
data = ellie.ice,
control = mpmm_control(
REML = TRUE,
verbose = 0 # turn off parameter trace for tidy output
)
)
summary(fit)
plot(fit)
```