Different distributions may be used depending on the kind of provided data. By default, the Poisson and negative binomial distributions are fitted to count data, whereas the binomial and beta-binomial distributions are used with incidence data. Either Randomness assumption (Poisson or binomial distributions) or aggregation assumption (negative binomial or beta-binomial) are made, and then, a goodness-of-fit comparison of both distributions is made using a log-likelihood ratio test.

## Usage

fit_two_distr(data, ...)

# S3 method for default
fit_two_distr(data, random, aggregated, ...)

# S3 method for count
fit_two_distr(
data,
random = smle_pois,
aggregated = smle_nbinom,
n_est = c(random = 1, aggregated = 2),
...
)

# S3 method for incidence
fit_two_distr(
data,
random = smle_binom,
aggregated = smle_betabinom,
n_est = c(random = 1, aggregated = 2),
...
)

## Arguments

data

An intensity object.

...

Additional arguments to be passed to other methods.

random

Distribution to describe random patterns.

aggregated

Distribution to describe aggregated patterns.

n_est

Number of estimated parameters for both distributions.

## Value

An object of class fit_two_distr, which is a list containing at least the following components:

 call The function call. name The names of both distributions. model The outputs of fitting process for both distributions. llr The result of the log-likelihood ratio test.

Other components can be present such as:

 param A numeric matrix of estimated parameters (that can be printed using printCoefmat). freq A data frame or a matrix with the observed and expected frequencies for both distributions for the different categories. gof Goodness-of-fit tests for both distributions (which are typically chi-squared goodness-of-fit tests).

## Details

Under the hood, distr_fit relies on the smle utility which is a wrapped around the optim procedure.

Note that there may appear warnings about chi-squared goodness-of-fit tests if any expected count is less than 5 (Cochran's rule of thumb).

Madden LV, Hughes G. 1995. Plant disease incidence: Distributions, heterogeneity, and temporal analysis. Annual Review of Phytopathology 33(1): 529–564. doi:10.1146/annurev.py.33.090195.002525