| Counts-class {dupiR} | R Documentation |
An S4 class to store measurements (count data, sampling fractions), prior support and posterior parameters
Description
An S4 class to store measurements (count data, sampling fractions), prior support and posterior parameters
Usage
## S4 method for signature 'Counts'
get_counts(object)
## S4 method for signature 'Counts'
get_fractions(object)
## S4 replacement method for signature 'Counts'
set_counts(object) <- value
## S4 replacement method for signature 'Counts'
set_fractions(object) <- value
## S4 method for signature 'Counts'
compute_posterior(
object,
n_start,
n_end,
replacement = FALSE,
b = 1e-10,
alg = "dup"
)
## S4 method for signature 'Counts'
get_posterior_param(object, low = 0.025, up = 0.975, ...)
## S4 method for signature 'Counts'
plot_posterior(object, low = 0.025, up = 0.975, xlab, step, ...)
Arguments
object |
object of class |
value |
numeric vector of sampling fractions |
n_start |
start of prior support range |
n_end |
end of prior support range |
replacement |
was sampling performed with replacement? Default to FALSE |
b |
prior rate parameter of the gamma distribution used to compute the posterior with Clough. Default to 1e-10 |
alg |
algorithm to be used to compute posterior. One of ... . Default to "dup" |
low |
1 - right tail posterior probability |
up |
left tail posterior probability |
... |
additional parameters to be passed to curve |
xlab |
x-axis label. Default to 'n' (no label) |
step |
integer defining the increment for x-axis labels (distance between two consecutive tick marks) |
Value
counts vector from a Counts object
fractions vector from a Counts object
an object of class Counts
an object of class Counts
an object of class Counts
an object of class Counts
no return value, called for side effects
Methods (by generic)
-
get_counts(Counts): Returns counts from aCountsobject -
get_fractions(Counts): Returns fractions from aCountsobject -
set_counts(Counts) <- value: Replaces counts of aCountsobject with the provided values -
set_fractions(Counts) <- value: Replaces fractions of aCountsobject with the provided values -
compute_posterior(Counts): Compute the posterior probability distribution of the population size -
get_posterior_param(Counts): Extract statistical parameters (e.g. credible intervals) from a posterior probability distribution -
plot_posterior(Counts): Plot posterior probability distribution and posterior parameters
Slots
countsinteger vector of counts (required)
fractionsnumeric vector of sampling fractions (required)
n_startstart of prior support range. If omitted and total
countsgreater than zero, computed as 0.5 *mle, wheremleis the maximum likelihood estimate of the population sizen_endend of prior support range. If omitted and total
countsgreater than zero, computed as 2 *mle, wheremleis the maximum likelihood estimate of the population sizef_productproduct of (1-
fractions)mlemaximum likelihood estimate of the population size (ratio between total counts and total sampling fraction)
norm_constantnormalization constant
posteriornumeric vector of posterior probabilities over the prior support
map_pmaximum of
posteriorprobabilitymap_indexindex of prior support corresponding to the maximum a posteriori
mapmaximum a posteriori of population size
q_lowlower bound of the credible interval
q_low_pprobability of the lower bound of the credible interval
q_low_indexindex of the prior support corresponding to
q_lowq_low_cum_pcumulative posterior probability from
n_starttoq_low(left tail)q_upupper bound of the credible interval
q_up_pprobability of the upper bound of the credible interval
q_up_indexindex of the prior support corresponding to
q_highq_up_cum_pcumulative posterior probability from
q_highton_end(right tail)gammalogical, TRUE if posterior computed using a Gamma approximation
Note
The posterior slot contains either the PMF or a logical value used to
compute posterior parameters with a Gamma approximation (see reference for details)
Lower and upper bounds of the credibile interval are computed at a default confidence level of 95
For more details on the normalization constant, see Corollary 1 in reference
Author(s)
Federico Comoglio
References
Comoglio F, Fracchia L and Rinaldi M (2013) Bayesian inference from count data using discrete uniform priors. PLoS ONE 8(10): e74388
See Also
compute_posterior, get_posterior_param
Examples
# constructor:
# create an object of class 'Counts'
new_counts(counts = c(30, 35), fractions = c(0.075, 0.1))
# same, using new
new("Counts", counts = c(30, 35), fractions = c(0.075, 0.1))