Description Usage Arguments Details Value Examples
View source: R/binary-cov-loglike.R
Calculate the likelihood for binary covariate MC trees
1 2 3 4 5 6 7 | bp_loglike_binary_cov(
inf_params,
obs_data_summary,
mc_samples_summary,
return_neg = FALSE,
messages = FALSE
)
|
inf_params |
vector of length 2, the beta0 and beta1 coefficients |
obs_data_summary |
|
mc_samples_summary |
a data frame of sampled transmission trees with the following columns,
|
return_neg |
logical indicating whether to return the negative loglike. Default is FALSE |
messages |
logical indicating whether we should print messages. Default is FALSE. |
WARNING: obs_data_summary and mc_samples_summary must not both have a 'freq' column.
the log average likelihood over the observed clusters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(dplyr)
inf_params <- c(-1, 1)
mc_samples_summary <- data.frame(freq = c(10, 5, 6, 1, 1),
mc_freq = c(10, 10, 10, 3, 7),
cluster_size = c(1, 1, 2, 2, 2),
x_pos = c(1, 0, 2, 1, 1),
x_neg = c(0, 1, 0, 1, 1),
x_pos_trans = c(0, 0, 1, 1, 0),
x_neg_trans = c(0, 0, 0, 0, 1))
obs_data_summary <- mc_samples_summary %>%
group_by(cluster_size, x_pos, x_neg) %>%
summarize(freq = sum(freq), .groups = "drop")
bp_loglike_binary_cov(inf_params = inf_params,
obs_data_summary = obs_data_summary,
mc_samples_summary = mc_samples_summary %>%
dplyr::select(-freq),
return_neg = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.