Skip to contents

Simulate data distributed according to oHMMed with gamma-poisson emission densities

Usage

hmm_simulate_gamma_poisson_data(L, mat_T, betas, alpha)

Arguments

L

(integer) number of simulations

mat_T

(matrix) a square matrix with the initial state

betas

(numeric) rate parameter in rgamma for emission probabilities

alpha

(numeric) shape parameter in rgamma for emission probabilities

Value

Returns a list with the following elements:

  • data: numeric vector with data

  • states: an integer vector with "true" hidden states used to generate the data vector

  • pi: numeric vector with prior probability of states

Examples

mat_T <- rbind(c(1-0.01, 0.01, 0),
               c(0.01, 1-0.02, 0.01),
               c(0, 0.01, 1-0.01))
L <- 2^7
betas <- c(0.1, 0.3, 0.5)
alpha <- 1

sim_data <- hmm_simulate_gamma_poisson_data(L = L,
                                            mat_T = mat_T,
                                            betas = betas,
                                            alpha = alpha)
hist(sim_data$data, 
     breaks = 40,
     main = "Histogram of Simulated Gamma-Poisson Data", 
     xlab = "")

sim_data
#> $data
#>   [1]  0 12  0  7  0  0  0  5  2  0  2  1  1  2  1  4  0  4  2  2  4  1  6  2  3
#>  [26]  0  3  6  5  7 15  2  2 14  1  7  7 12  0  1  1  5  1  0  5  3  3  0  1  1
#>  [51]  6  4  4  1  5  1  6  6  0  5  2  3  0  2  4  2  4 22 22  1  1  4  2  5  9
#>  [76]  3 18  4  2  1  0 30  0  3  8 16 20  4  1  4 23 24 19  2  3  6  6  0 38  3
#> [101]  7 81  4  1  1  5 34  2  5  6  7 19  0  1 13  0 33  6  8  5 15 12  6 15  7
#> [126]  3 15  5
#> 
#> $states
#>   [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 2 2 2
#>  [38] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
#>  [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [112] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> Levels: 1 2 3
#> 
#> $pi
#> [1] 0.3333333 0.3333333 0.3333333
#>