knitr::opts_chunk$set( collapse = TRUE, comment = ">", fig.height = 1 ) library(mmre)
R
package to fit two-stare continuous-time discrete-space Markov models with individual level random effects.
Methodology was developed with Enrico Pirotta to assess the effects of exposure
to Navy sonar on marine mammal movement patterns.
To install the mmre
package run
devtools::install_github("cmjt/mmre") library(mmre)
All model likelihoods are coded using TMB
; in oder to compile all TMB
templates after installation run
compile.mmre()
and to load the templates run
dll.mmre()
once in each workspace.
The mmre
package contains an example dataset, example$data
, of three individuals on the AUTEC Naval range (see figure below).
The state
variable indicate if an individual was off (state = 1) or on (state = 2) range (black polygon in figure). Id
is the individual ID (individual_i for i = 1,2,3). The time
column gives the relative times os the observations in days and the t.since
column gives, in days, the time since an individual was esposed to Navy sonar activity.
knitr::include_graphics("figure/AUTEC.png")
data(example)
To fit a simple two state continuous-time Markov model run
mod.basic <- fit.mmre(data = example$data,parameters = list(log_baseline = log(c(0.5,0.5))))
and to get the estimated transition probability matrix P(t = 1)
get.probs(mod.basic,1)
To compare the results to the msm
package run
library(msm) msm.fit <- msm(state ~ time, subject = ID, data = example$data, qmatrix = rbind(c(0, 0.5), c(0.5, 0)), exacttimes = FALSE) pmatrix.msm(msm.fit)
mod.basic.re <- fit.mmre(data = example$data,parameters = example$parameters.basic.re)
get.probs(mod.basic.re,1)
mod.decay.re <- fit.mmre(data = example$data,parameters = example$parameters.decay.re, decay = TRUE, cov.names = "t.since")
get.coefs(mod.decay.re)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.