extract_empirical_clusters {jlmerclusterperm} | R Documentation |
Detect largest clusters from a time sequence of predictor statistics
Description
Detect largest clusters from a time sequence of predictor statistics
Usage
extract_empirical_clusters(
empirical_statistics,
threshold,
binned = FALSE,
top_n = Inf
)
Arguments
empirical_statistics |
A predictor-by-time matrix of empirical timewise statistics. |
threshold |
The threshold value that the statistic must pass to contribute to cluster mass. Interpretation differs on the choice of statistic (more below):
|
binned |
Whether the data has been aggregated/collapsed into time bins. Defaults to |
top_n |
How many clusters to return, in the order of the size of the cluster-mass statistic.
Defaults to |
Value
An empirical_clusters
object.
See Also
Examples
library(dplyr, warn.conflicts = FALSE)
# Specification object
spec <- make_jlmer_spec(
weight ~ 1 + Diet, filter(ChickWeight, Time <= 20),
subject = "Chick", time = "Time"
)
spec
# Empirical clusters are derived from the timewise statistics
empirical_statistics <- compute_timewise_statistics(spec)
empirical_clusters <- extract_empirical_clusters(empirical_statistics, threshold = 2)
empirical_clusters
# Collect as dataframe with `tidy()`
empirical_clusters_df <- tidy(empirical_clusters)
empirical_clusters_df
# Changing the `threshold` value identifies different clusters
extract_empirical_clusters(empirical_statistics, threshold = 1)
# A predictor can have zero or multiple clusters associated with it
extract_empirical_clusters(empirical_statistics, threshold = 3)