View source: R/para_prevalence_CI.R
| para_prevalence_CI | R Documentation |
Estimates parasite prevalence and corresponding confidence intervals from parasite abundance data, optionally stratified by grouping variables. Two types of CIs are provided: exact binomial intervals and Blaker intervals, allowing robust inference across a wide range of sample sizes and prevalence values.
para_prevalence_CI(dataset, sp_cols, group_vars = NULL, decimal_places = 2,
conf_level = 0.95, ci_method = "wilson", output_type = "proportion",
combine_ci = FALSE, save_csv = FALSE, verbose = FALSE)
dataset |
Data frame with parasitological data. |
sp_cols |
Vector with the names of the columns containing abundance of parasites (taxa) to calculate the parasitological descriptors. |
group_vars |
Vector with the names of categorical variables used to define groups (e.g., "Sex", "Site"). Default is |
decimal_places |
Number of decimal places to round the values. Default is |
conf_level |
Confidence level for the interval estimation (e.g., |
ci_method |
Method used to estimate prevalence CIs. Options are |
output_type |
Format of the result: either |
combine_ci |
Logical. If |
save_csv |
Logical. If |
verbose |
Logical. If |
Prevalence is defined as the proportion of hosts infected with a given parasite taxon:
P = \frac{nH_{inf}}{nH}
where:
nH is the number of hosts analyzed (non-missing observations)
nH_{inf} nHinf is the number of infected hosts (abundance > 0)
The function reshapes the dataset into long format and computes prevalence for each parasite taxon and grouping combination (if specified). Two types of CIs are calculated:
Exact (Clopper–Pearson) interval: This is an exact binomial CI, conservative but valid for all sample sizes, especially small samples or extreme prevalence values.
Blaker interval: This interval is also exact but less conservative than Clopper–Pearson, providing shorter intervals while maintaining correct coverage.
Statistical considerations:
Prevalence is a binomial proportion and can be estimated even for small sample sizes.
However, when sample size is very small (e.g., nH=1), the estimate lacks precision and CIs become uninformative.
When no infected hosts are observed (nH_{inf}=0), prevalence is 0, and CIs reflect uncertainty around zero.
The interpretation of results, particularly under small sample sizes, remains the responsibility of the user.
A data frame containing prevalence estimates and CIs for each parasite taxon, either globally or by group. The following variables are returned:
nH: Number of hosts analyzed
nH_inf: Number of infested hosts
prevalence: Estimated prevalence
Lower_<ci_method>: Lower bound of the prevalence CI estimated using the method specified in ci_method ("wilson", "exact", or "blaker").
Upper_<ci_method>: Upper bound of the prevalence CI estimated using the method specified in ci_method ("wilson", "exact", or "blaker").
CI_<ci_method>: If combine_ci = TRUE, CI stored as a single column (Lower_<ci_method> - Upper_<ci_method>).
Observation: Categorical description of the data context:
"Not analyzed": No valid observations are available for the given combination (all values are missing or the combination is absent in the dataset); therefore, no estimates can be computed.
"One host analyzed": Only a single host analyzed is available for the given combination; thus, no population-level inference is possible and statistical summary measures are not estimated.
"No hosts infested": Hosts are present for the given combination, but none are infested (abundance = 0 for all observations); consequently, no statistical summary measures of abundance or intensity can be estimated.
"One host infested": Only a single infested host is recorded for the given combination; therefore, no sample-based estimation of intensity or related summary measures is possible.
"Multiple hosts infested": More than one infested host is recorded for the given combination, allowing the estimation of summary measures.
Juan Manuel Cabrera, Exequiel Furlan and Elisa Helman
Bush, A.O., Lafferty, K.D., Lotz, J.M., Shostak, A.W. (1997). Parasitology meets ecology on its own terms: Margolis revisited. Journal of Parasitology, 83(4), 575–583.
Reiczigel, J., Marozzi, M., Fabian, I., Rózsa, L. (2019). Biostatistics for parasitologists – a primer to quantitative parasitology. Trends in Parasitology, 35(4), 277–281.
prevalence_CI <- para_prevalence_CI(para_data$dataset,
sp_cols = c("Sp1"),
group_vars = c("Site"),
decimal_places = 2,
conf_level = 0.95,
ci_method = "wilson",
output_type = "proportion",
combine_ci = TRUE,
save_csv = FALSE,
verbose = TRUE)
prevalence_CI
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.