update_behav_param: Simulate behaviour parameters.

Description Usage Arguments Value See Also Examples

Description

update_behav_param returns a conditional Gibbs sample of the behaviour parameters.

Usage

1
update_behav_param(fixed_constant, behav_proc)

Arguments

fixed_constant

List with components:

num_states

Numeric, number of behavioural states.

prior_param

List with components:

lambda_rate

Vector (length num_states) with prior rate of the switching rates.

lambda_shape

Vector (length num_states) with prior shape of the switching rates.

q_conc

Matrix (square, size num_states with NA diagonal elements) with prior concentration of the switching probabilities.

behav_proc

List with components:

times

Vector, switch times of the behaviour process.

states

Vector, behavioural states at switching times.

Value

List with the components:

lambda

Vector (length num_states) of sampled switching rates.

q

Matrix (square size num_states with NA diagonal elements) of sampled switching probabilities. Note: row = from, column = to.

See Also

Other Behaviour parameters: calc_markov_post_param, calc_markov_suff_stats, check_valid_markov

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
const <- list(prior_param = list(lambda_rate = c(0.1, 0.2),
                                 lambda_shape = c(2, 1),
                                 q_conc = matrix(c(NA, 1, 1, NA), nrow = 2)),
              num_states = 2)
behav_proc <- list(times = c(0, 12, 15, 20, 26, 43, 50),
                   states = c(1, 2, 1, 2, 1, 2, 2))

set.seed(1234)
update_behav_param(const, behav_proc)
# $lambda
# [1] 0.06755656 0.18652884
#
# $q
# [,1] [,2]
# [1,]   NA    1
# [2,]    1   NA

const <- list(prior_param = list(lambda_rate = c(0.1, 0.2, 0.3),
                                 lambda_shape = c(4, 3, 2),
                                 q_conc = matrix(c(NA, 0.5, 0.3, 0.2, NA, 0.7, 0.8, 0.5, NA), nrow = 3)),
              num_states = 3)
behav_proc <- list(times = c(100, 140, 167, 189, 241, 264, 279, 304, 365, 397, 400),
                   states = c(1, 2, 1, 3, 2, 3, 1, 2, 3, 2, 2))

set.seed(7654)
update_behav_param(const, behav_proc)
# $lambda
# [1] 0.04658404 0.05334004 0.08813678
#
# $q
# [,1]      [,2]      [,3]
# [1,]          NA 0.6686524 0.3313476
# [2,] 0.008780271        NA 0.9912197
# [3,] 0.366922353 0.6330776        NA

a-parton/CTStepTurn documentation built on May 14, 2019, 4:17 p.m.