dsdive.obsld_approx: Likelihood for collection of partially observed dives

Description Usage Arguments Examples

View source: R/dsdive.obsld_approx.R

Description

Likelihood for collection of partially observed dives

Usage

1
2
3
4
5
6
7
8
9
dsdive.obsld_approx(
  dsobs.list,
  t.stages.list,
  s0,
  sf,
  beta,
  lambda,
  P.interpolator
)

Arguments

dsobs.list

list of dsobs objects, which describe the observation times and depths of a collection of dives

t.stages.list

list of stage transition times for dives observed in dsobs.list

s0

likelihood should include contributions for stages greater or equal to s0

sf

likelihood should include contributions for stages less than or equal to sf

beta

vector with directional preference parameters for descent and ascent stages.

lambda

vector with dive rate parameters for the descent, bottom, and ascent stages.

P.interpolator

list of functions to approximate transition probabilities in a given stage, given model parameters, and a timestep

Examples

 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
data('dive.sim')
attach(dive.sim)
attach(dive.sim$params)

library(parallel)


#
# build interpolating functions
#

cl = makeCluster(spec = 3, type = 'SOCK')
clusterEvalQ(cl, library(dsdive))

interpolators = lapply(1:3, function(s0) {
  
  # support for directional preferences, speeds, and timesteps
  if(s0 == 1) {
    beta.seq = seq(.5, 1, length.out = 7)
    beta.seq[length(beta.seq)] = .999
    lambda.seq = seq(.1, 2, length.out = 7)
    tstep.seq = seq(0, 300, by = 100)
  } else if(s0 == 2) {
    beta.seq = .5
    lambda.seq = seq(.1, 2, length.out = 7)
    tstep.seq = seq(0, 300, by = 100)
  } else if(s0 == 3) {
    beta.seq = seq(0, .5, length.out = 7)
    beta.seq[1] = 1-.999
    lambda.seq = seq(.1, 2, length.out = 7)
    tstep.seq = seq(0, 300, by = 100)
  }
  
  interpolators = dsdive.obstx.matrix_interpolator(
    depth.bins = depth.bins, beta.seq = beta.seq, lambda.seq = lambda.seq,
    s0 = s0, tstep.seq = tstep.seq, m = 3, verbose = TRUE, cl = cl)
  
})

stopCluster(cl = cl)

# get true stage transition times
t.stages = sim$times[c(FALSE, diff(sim$stages)==1)]

# compute likelihood of observations, given model parameters
ld = dsdive.obsld_approx(dsobs.list = list(sim.obs,sim.obs),
                         t.stages.list = list(t.stages,t.stages), 
                         s0 = 1, sf = 3, beta = params$beta, 
                         lambda = params$lambda, P.interpolator = interpolators)

detach(dive.sim$params)
detach(dive.sim)

jmhewitt/dsdive documentation built on May 29, 2020, 5:18 p.m.