chain_ll: Calculate the log-likelihood for the outcome of a branching...

View source: R/likelihoods.R

chain_llR Documentation

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

Description

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)

Author(s)

Sebastian Funk

See Also

pois_size_ll, nbinom_size_ll, gborel_size_ll, pois_length_ll, geom_length_ll, offspring_ll

Examples

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

sbfnk/bpmodels documentation built on Nov. 7, 2023, 5:16 a.m.