Learn R Programming

BayesChange (version 2.1.3)

detect_cp_epi: Detect Change Points on a epidemic diffusion

Description

Detect Change Points on a epidemic diffusion

Usage

detect_cp_epi(
  data,
  n_iterations,
  q,
  M,
  xi,
  a0,
  b0,
  I0_var = 0.01,
  print_progress = TRUE,
  user_seed = 1234L
)

Value

Function detect_cp_epi returns a list containing the following components:

  • $orders a matrix where each row corresponds to the output order of the corresponding iteration.

  • time computational time in seconds.

  • $I0_MCMC traceplot for \(I_0\).

  • $I0_MCMC_01 a \(0/1\) vector, the \(n\)-th element is equal to \(1\) if the proposed \(I_0\) was accepted, \(0\) otherwise.

Arguments

data

a matrix where each column is a component of the epidemic diffusion and the rows correspond to the times.

n_iterations

number of MCMC iterations.

q

probability of performing a split at each iteration.

M

number of Monte Carlo iterations when computing the likelihood of the epidemic diffusion.

xi

recovery rate fixed constant for each population at each time.

a0, b0

parameters for the computation of the integrated likelihood of the epidemic_diffusions.

I0_var

variance for the Metropolis-Hastings estimation of the proportion of infected at time 0.

print_progress

If TRUE (default) print the progress bar.

user_seed

seed for random distribution generation.

Examples

Run this code
# \donttest{
data_mat <- matrix(NA, nrow = 100, ncol = 1)

betas <- c(rep(0.45, 25),rep(0.14,75))

inf_times <- sim_epi_data(10000, 10, 100, betas, 1/8)

inf_times_vec <- rep(0,100)
names(inf_times_vec) <- as.character(1:100)

for(j in 1:100){
 if(as.character(j) %in% names(table(floor(inf_times)))){
 inf_times_vec[j] = table(floor(inf_times))[which(names(table(floor(inf_times))) == j)]
 }
}

data_mat[,1] <- inf_times_vec

out <- detect_cp_epi(data = data_mat, n_iterations = 250, q = 0.5,
                     xi = 1/8, a0 = 40, b0 = 10, M = 250)

# }

Run the code above in your browser using DataLab