bp_loglike_binary_cov: Calculate the likelihood for binary covariate MC trees

Description Usage Arguments Details Value Examples

View source: R/binary-cov-loglike.R

Description

Calculate the likelihood for binary covariate MC trees

Usage

1
2
3
4
5
6
7
bp_loglike_binary_cov(
  inf_params,
  obs_data_summary,
  mc_samples_summary,
  return_neg = FALSE,
  messages = FALSE
)

Arguments

inf_params

vector of length 2, the beta0 and beta1 coefficients

obs_data_summary
cluster_size

number in cluster

x_pos

number of positive smears in cluster

x_neg

number of negative smears in the cluster

freq

number of times this frequency occurs

mc_samples_summary

a data frame of sampled transmission trees with the following columns,

x_pos_trans

number of total transmissions from any smear positive person

x_pos

number of positive smears

x_neg

number of negative smears

cluster_size

cluster size

mc_freq

number of samples

return_neg

logical indicating whether to return the negative loglike. Default is FALSE

messages

logical indicating whether we should print messages. Default is FALSE.

Details

WARNING: obs_data_summary and mc_samples_summary must not both have a 'freq' column.

Value

the log average likelihood over the observed clusters

Examples

 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)

skgallagher/InfectionTrees documentation built on July 28, 2021, 2:14 p.m.