View source: R/ct_overlap_matrix.R
| ct_overlap_matrix | R Documentation |
This function calculates pairwise overlap coefficients for activity patterns of multiple species using their time data, and optionally bootstrap confidence intervals for every pair.
ct_overlap_matrix(
data,
species_column,
time_column,
convert_time = FALSE,
format = "%H:%M:%S",
fill_na = NULL,
n_boot = 0,
conf = 0.95,
ci_method = c("auto", "norm", "norm0", "basic", "basic0", "perc"),
cores = 1,
...
)
data |
A |
species_column |
A column in |
time_column |
A column in |
convert_time |
Logical. If |
format |
A character string specifying the time format (e.g., |
fill_na |
Optional. A numeric value used to fill |
n_boot |
Integer. Number of bootstrap samples used to derive a confidence
interval for each species pair. When |
conf |
Numeric scalar in |
ci_method |
Character. How to choose the confidence-interval type returned
by |
cores |
Integer. Number of cores passed to |
... |
Additional arguments passed to |
The function calculates pairwise overlap coefficients for all species in the dataset.
The overlap coefficients are estimated using the overlap package:
For species pairs with sample sizes of at least 50 observations each, the Dhat4 estimator is used.
For smaller sample sizes, the Dhat1 estimator is used (Schmid & Schmidt, 2006).
When n_boot > 1, each pair is bootstrapped with the same estimator used for
its point estimate, and a confidence interval is obtained through ct_boot_ci().
Because the coefficient stored in
the matrix is the uncorrected estimate, the "auto" selection restricts
itself to the interval types, namely "norm0" and
"basic0"; the choice between them is made per pair from a normality check on
the bootstrap estimates. Pairs for which the bootstrap or interval cannot be
computed receive NA.
If n_boot <= 1, a square numeric matrix of pairwise overlap coefficients,
where rows and columns represent species (the original return value).
If n_boot > 1, a named list of matrices:
estimatethe square numeric matrix of overlap coefficients;
cia character matrix whose cells give the confidence interval as
"[lower ; upper]";
ci_methoda character matrix recording which ct_boot_ci()
interval type was used for each cell if ci_method is "auto";
Schmid & Schmidt (2006) Nonparametric estimation of the coefficient of overlapping - theory and empirical application, Computational Statistics and Data Analysis, 50:1583-1596.
overlap::overlapEst() for overlap coefficient estimation;
ct_bootstrap() and ct_boot_ci() for the bootstrap machinery.
# Example dataset
data <- data.frame(
species = c("SpeciesA", "SpeciesA", "SpeciesB", "SpeciesB"),
time = c("10:30:00", "11:45:00", "22:15:00", "23:30:00")
)
# Calculate overlap coefficients with time conversion
overlap_matrix <- ct_overlap_matrix(
data = data,
species_column = species,
time_column = time,
convert_time = TRUE,
format = "%H:%M:%S"
)
# With bootstrap confidence intervals (returns a list of matrices)
overlap_ci <- ct_overlap_matrix(
data = data,
species_column = species,
time_column = time,
convert_time = TRUE,
n_boot = 99,
conf = 0.95
)
overlap_ci$estimate
overlap_ci$ci
overlap_ci$ci_method
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.