Maximum likelihood test and plotted results for coinfection dynamics

cooccurence_test(
  data,
  density_func = independent,
  max_moi = 25,
  poisson = FALSE,
  size = 100,
  boot_iter = 10000,
  plot = TRUE,
  quantiles = c(0.025, 0.975),
  lower = NULL,
  upper = NULL,
  ...
)

Arguments

data

Observed data. Either as a named vector or a 2 column data.frame. See examples for more info.

density_func

Function that calculates the multinomial distribution describing the data. Default = independent

max_moi

Maxuimum infction composition explored. Default = 25.

poisson

Logical for determining if we use a poisson distribution to describe the numer of infection occurences. Default = `FALSE`, which means a negative binomial is used. `

size

Starting value for the negative binomial size parameter. Default = 100.

boot_iter

Bootstrap iterations. Default = 10000

plot

Boolean for default plotting the bootsrap results. Default = TRUE

quantiles

Vector of length 2 for the quantiles used. Default = `c(0.025, 0.975)`

lower

Vector of lower bounds used in fitting. Default = NULL, which will create a vector with 0.0001 for each frequency and 0.1 for the moi.

upper

Vector of upper bounds used in fitting. Default = NULL, which will create a vector with 0.9999 for each frequency and `max_moi` for the moi.

...

Any other arguments that will be passed to `density_func``

Value

Invisibly returns a list containing the estimated parameters and a plot of our data compared to the boostrapped estimates.

Details

Estimates the maximum likely population frequency of each species (i.e. the names of the observed entities in our data) and the mean number of infections given our observed data. These estimates are used to estimate the multinomial probability distribution for all cooccurences and comparing these to our data using a boostrap method.

Examples

if (FALSE) { # example of the two forms of data type accepted real <- data.frame( "variable"=c("pf/po","pf/pv","pf/po/pv","pf","po","po/pv","pv"), "value"=c(84,179,1,5181,44,1,309) ) real <- c( "pf/po" = 84, "pf/pv" = 179, "pf/po/pv" = 1, "pf" = 5181, "po" = 44, "po/pv" = 1, "pv" = 309 ) res <- cooccurence_test(data = real) }