fitMRH: Fit a Moving-Resting-Handling Model with Embedded Brownian...

View source: R/fitMovResHan.R

fitMRHR Documentation

Fit a Moving-Resting-Handling Model with Embedded Brownian Motion

Description

Fit a Moving-Resting-Handling Model with Embedded Brownian Motion with animal movement data at discretely observation times by maximizing a full likelihood. Using segment to fit part of observations to the model. A practical application of this feature is seasonal analysis.

Usage

fitMRH(
  data,
  start,
  segment = NULL,
  numThreads = RcppParallel::defaultNumThreads() * 3/4,
  lower = c(0.001, 0.001, 0.001, 0.001, 0.001),
  upper = c(10, 10, 10, 10, 0.999),
  integrControl = integr.control(),
  print_level = 3
)

Arguments

data

a data.frame whose first column is the observation time, and other columns are location coordinates. If segment is not NULL, additional column with the same name given by segment should be included. This additional column is used to indicate which part of observations shoule be used to fit model. The value of this column can be any integer with 0 means discarding this observation and non-0 means using this obversvation. Using different non-zero numbers indicate different segments. (See vignette for more details.)

start

The initial value for optimization, in the order of rate of moving, rate of resting, rate of handling, volatility and switching probability.

segment

character variable, name of the column which indicates segments, in the given data.frame. The default value, NULL, means using whole dataset to fit the model.

numThreads

int, the number of threads allocated for parallel computation. The default setup is 3/4 available threads. If this parameter is less or equal to 1, the serial computation will be processed.

lower, upper

Lower and upper bound for optimization.

integrControl

Integration control vector includes rel.tol, abs.tol, and subdivisions.

print_level

print_level passed to nloptr::nloptr. Possible values: 0 (default): no output; 1: show iteration number and value of objective function; 2: 1 + show value of (in)equalities; 3: 2 + show value of controls.

Value

A list of estimation result with following components:

estimate

the estimated parameter vector

loglik

maximized loglikelihood or composite loglikelihood evaluated at the estimate

convergence

convergence code from nloptr

data

fitted data

Author(s)

Chaoran Hu

References

Pozdnyakov, V., Elbroch, L.M., Hu, C. et al. On Estimation for Brownian Motion Governed by Telegraph Process with Multiple Off States. Methodol Comput Appl Probab 22, 1275–1291 (2020). doi:10.1007/s11009-020-09774-1

See Also

rMRH for simulation.

Examples

## Not run: 
## time consuming example
set.seed(06269)
tgrid <- seq(0, 400, by = 8)
dat <- rMRH(tgrid, 4, 0.5, 0.1, 5, 0.8, 'm')
fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8)) ## parallel process
fitMRH(dat, c(4, 0.5, 0.1, 5, 0.8), numThreads = -1) ## serial process

## fit part of dataset to the MRH model
batch <- c(rep(0, 10), rep(1, 7), rep(0, 10), rep(2, 10), rep(0, 14))
dat.segment <- cbind(dat, batch)
fit.segment <- fitMRH(dat.segment, start = c(4, 0.5, 0.1, 5, 0.8), segment = "batch")
head(dat.segment)
fit.segment

## End(Not run)


smam documentation built on Aug. 21, 2023, 9:09 a.m.

Related to fitMRH in smam...