clust_cp_epi | R Documentation |
Clustering Epidemiological survival functions with common changes in time
clust_cp_epi(
data,
n_iterations,
M,
B,
L,
xi = 1/8,
alpha_SM = 1,
q = 0.1,
a0 = 4,
b0 = 10,
I0_var = 0.01,
avg_blk = 0.003,
print_progress = TRUE,
user_seed = 1234L
)
data |
a matrix where each entry is the number of infected for a population (row) at a specific discrete time (column). |
n_iterations |
Second value |
M |
number of Monte Carlo iterations when computing the likelihood of the survival function. |
B |
number of orders for the normalisation constant. |
L |
number of split-merge steps for the proposal step. |
xi |
recovery rate fixed constant for each population at each time. |
alpha_SM |
|
q |
probability of performing a split when updating the single order for the proposal procedure. |
a0 , b0 |
parameters for the computation of the integrated likelihood of the survival functions. |
I0_var |
variance for the Metropolis-Hastings estimation of the proportion of infected at time 0. |
avg_blk |
average number of change points for the random generated orders. |
print_progress |
If TRUE (default) print the progress bar. |
user_seed |
seed for random distribution generation. |
Function clust_cp_epi
returns a list containing the following components:
$clust
a matrix where each row corresponds to the output cluster of the corresponding iteration.
$orders
a multidimensional matrix where each slice is a matrix with the orders associated to the output cluster of that iteration.
time
computational time in seconds.
$llik
a matrix containing the log-likelihood of each population at each iteration.
$rho
traceplot for the proportion of infected individuals at time 0.
data_mat <- matrix(NA, nrow = 5, ncol = 50)
betas <- list(c(rep(0.45, 25),rep(0.14,25)),
c(rep(0.55, 25),rep(0.11,25)),
c(rep(0.50, 25),rep(0.12,25)),
c(rep(0.52, 10),rep(0.15,40)),
c(rep(0.53, 10),rep(0.13,40)))
inf_times <- list()
for(i in 1:5){
inf_times[[i]] <- sim_epi_data(10000, 10, 50, betas[[i]], 1/8)
vec <- rep(0,50)
names(vec) <- as.character(1:50)
for(j in 1:50){
if(as.character(j) %in% names(table(floor(inf_times[[i]])))){
vec[j] = table(floor(inf_times[[i]]))[which(names(table(floor(inf_times[[i]]))) == j)]
}
}
data_mat[i,] <- vec
}
out <- clust_cp_epi(data = data_mat, n_iterations = 3000, M = 250, B = 1000, L = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.