dsdive.obstxmat.cov: Compute probability transition matrix for partially observed...

Description Usage Arguments Examples

View source: R/dsdive.obstxmat.cov.R

Description

Given model parameters, this function will compute the probability transition matrix for a Continuous time Markov chain (CTMC) that is observed once, and then again at a time of tstep units of time later. If include.raw==TRUE, then raw components of the probability transition matrix will be returned so that the transition matrix can be computed for arbitrary timesteps.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
dsdive.obstxmat.cov(
  pi.designs,
  lambda.designs,
  beta1,
  beta2,
  alpha1,
  alpha2,
  alpha3,
  s0,
  ind,
  tstep,
  include.raw,
  depth.bins,
  delta
)

Arguments

pi.designs

list of design matrices for the diving preference parameters by stage.

lambda.designs

list of design matrices for the diving speed parameters by stage.

beta1

coefficient values for linear model for logit(pi^(1)).

beta2

coefficient values for linear model for logit(pi^(3)).

alpha1

coefficient values for linear model for log(lambda^(1)).

alpha2

coefficient values for linear model for log(lambda^(2)).

alpha3

coefficient values for linear model for log(lambda^(3)).

s0

stage for which the transition matrix should be computed

ind

transition matrix is unique for each dive. The parameter ind specifies that the transition matrix should be computed for the dive associated with the covariates in row ind in the design matrices (see pi.designs, lambda.designs).

tstep

Time between observations of the CTMC

include.raw

TRUE to include raw components of the probability transition matrix so that the matrix can be computed for arbitrary timesteps

depth.bins

n x 2 Matrix that defines the depth bins. The first column defines the depth at the center of each depth bin, and the second column defines the half-width of each bin.

delta

If delta>0, then the observation matrix and raw components computed will be for a transition matrix whose generator is perturbed to allow much faster computation.

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

beta1 = c(0, 0)
beta2 = c(0, 0)
alpha1 = c(0, 0)
alpha2 = c(0, 0)
alpha3 = c(0, 0)

covs = data.frame(x1 = c(.5, 1), x2 = c(0, .3))

pi.formula = ~x1
lambda.formula = ~x1:x2


#
# expand covariate design matrices
#

if(!inherits(pi.formula, 'list')) {
  pi.formula = list(pi.formula, pi.formula)
}

if(!inherits(lambda.formula, 'list')) {
  lambda.formula = list(lambda.formula, lambda.formula, lambda.formula)
}

pi.designs = lapply(pi.formula, function(f) model.matrix(f, covs))
lambda.designs = lapply(lambda.formula, function(f) model.matrix(f, covs))


#
# build transition matrix
#

m = dsdive.obstxmat.cov(
  pi.designs = pi.designs, lambda.designs = lambda.designs, beta1 = beta1, 
  beta2 = beta2, alpha1 = alpha1, alpha2 = alpha2, alpha3 = alpha3, s0 = 1, 
  ind = 1, tstep = 300, include.raw = TRUE, depth.bins = depth.bins, 
  delta = 1e-10)

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

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