CooccurrenceAffinity
Short summary
An R package for computing affinity metrics between co-occurring entities using presence/absence data. Key functions include:
affinity(data, row.or.col, ...): compute pairwise affinity statistics (MLE of alpha, expected co-occurrence, p-values, and optional square matrices) from presence/absence dataAlphInts(x, mA_mB_N, lev, pvalType, ...): calculate various confidence intervals for alpha, including conservative (Clopper–Pearson, Blaker) and mid-P methodsML.Alpha(x, mA_mB_N, lev, ...): compute the maximum likelihood estimate of alpha and related likelihood-based metrics for co-occurrence countsplotgg(data, variable, legendlimit, ...): create configurable ggplot2 heatmaps of affinity outputs with customizable legends, text size, and color scales
Quick install & start
The library can be installed from CRAN or GitHub.
# CRAN version
install.packages("CooccurrenceAffinity")
library(CooccurrenceAffinity)
# Load example data and compute affinity
data(finches)
res <- affinity(data = finches, row.or.col = "col")
CovrgPlot(marg = c(50,70,150), lev = 0.95)
plotgg(data = res, variable = "alpha_mle", legendlimit = "balanced")