Skip to contents

Calculate the log-likelihood for the outcome of a branching process

Usage

chain_ll(
  x,
  offspring,
  stat = c("size", "length"),
  obs_prob = 1,
  infinite = Inf,
  exclude = NULL,
  individual = FALSE,
  nsim_obs,
  ...
)

Arguments

x

vector of sizes or lengths of transmission chains

offspring

Offspring distribution: a character string corresponding to the R distribution function (e.g., "pois" for Poisson, where rpois is the R function to generate Poisson random numbers)

stat

statistic given as x ("size" or "length" of chains)

obs_prob

observation probability (assumed constant)

infinite

any chains of this size/length will be treated as infinite

exclude

any sizes/lengths to exclude from the log-likelihood calculation

individual

if TRUE, a vector of individual log-likelihood contributions will be returned rather than the sum

nsim_obs

number of simulations if the log-likelihood is to be approximated for imperfect observations

...

parameters for the offspring distribution

Value

log-likelihood, or vector of log-likelihoods (if obs_prob < 1), or a list of individual log-likelihood contributions (if individual=TRUE)

See also

pois_size_ll, nbinom_size_ll, gborel_size_ll, pois_length_ll, geom_length_ll, offspring_ll

Author

Sebastian Funk

Examples

chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes
chain_ll(chain_sizes, "pois", "size", lambda = 0.5)
#> [1] -8.607196