calc_markov_suff_stats: Calculate Markov chain sufficient statistics.

Description Usage Arguments Value See Also Examples

Description

calc_markov_suff_stats calculates the sufficient statistics (time in each state and the number of transitions between state pairs) for a Markov chain.

Usage

1
calc_markov_suff_stats(num_states, switch_times, switch_states)

Arguments

num_states

Numeric, number of behavioural states.

switch_times

Vector, times of behavioural switches.

switch_states

Vector, states at switching times.

Value

List with components:

time_in_state

Vector (length num_states) with total time spent in each behavioural state.

num_trans

Matrix (square, size num_states with NA diagonal elements) with number of transitions from each state (row) to every other (column).

See Also

Other Behaviour parameters: calc_markov_post_param, check_valid_markov, update_behav_param

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
times <- c(0, 12, 15, 20, 26, 43, 50)
states <- c(1, 2, 1, 2, 1, 2, 2)

calc_markov_suff_stats(2, times, states)
# $time_in_state
# [1] 34 16
#
# $num_trans
# [,1] [,2]
# [1,]   NA    3
# [2,]    2   NA

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)
calc_markov_suff_stats(3, times, states)
# time_in_state
# [1]  87 114  99
#
# $num_trans
# [,1] [,2] [,3]
# [1,]   NA    2    1
# [2,]    1   NA    2
# [3,]    1    2   NA

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