Computes correlation coefficients between mcmodule inputs and outputs using
tornado analysis (from the
mc2d package). Supports multiple correlation methods
and captures warnings generated during calculation.
mcmodule_corr(
mcmodule,
output = NULL,
by_exp = FALSE,
match_variates = TRUE,
variates_as_nsv = FALSE,
print_summary = TRUE,
progress = FALSE,
method = c("spearman", "kendall", "pearson"),
use = "all.obs",
lim = c(0.025, 0.975)
)A data frame with correlation coefficients and metadata. Columns include:
exp: Expression name
exp_n: Expression number
variate: Variate number
output: Output node name
input: Input node name
value: Correlation coefficient value
strength: Qualitative strength of association (Very strong, Strong, Moderate, Weak, None)
method: Correlation method used (spearman, kendall, or pearson)
use: Method for handling missing values (passed to the correlation function)
warnings: Any warnings generated during correlation calculation (if present)
Additional columns for global keys (e.g., pathogen, origin)
(mcmodule object). Module containing simulation results.
(character, optional). Output node name. If NULL (default), uses
the last node in mcmodule$node_list. If by_exp = TRUE, uses the last
output node per expression. Default: NULL.
(logical). If TRUE, calculate correlations by expression output; if FALSE, use global output (last node). Default: FALSE.
(logical). If TRUE, match input nodes to output variates when data dimensions differ. Default: TRUE.
(logical). If TRUE, combine all variates into one mc
object; if FALSE, analyse each variate separately. See mcmodule_to_mc().
Default: FALSE.
(logical). If TRUE, print correlation analysis summary. Default: TRUE.
(logical). If TRUE, print progress information while running. Default: FALSE.
(character). Correlation coefficient type: "spearman" (default),
"kendall", or "pearson". See stats::cor(). Default: "spearman".
(character). Method for handling missing values: "all.obs",
"complete.obs", or "pairwise.complete.obs". See stats::cor().
Default: "all.obs".
(numeric vector). Quantiles for credible interval computation (reserved
for two-dimensional models). Default: c(0.025, 0.975).
mcmodule <- agg_totals(
mcmodule = imports_mcmodule,
mc_name = "no_detect_a",
agg_keys = "pathogen"
)
cor_results <- mcmodule_corr(mcmodule)
# Use single method
cor_results_spearman <- mcmodule_corr(mcmodule, method = "spearman")
Run the code above in your browser using DataLab