View source: R/canonical-interface.R
| gseg2 | R Documentation |
Detects an interval whose distribution differs from the remainder of a sequence. Given observations or dissimilarities, the function constructs a k-MST and applies the max-type edge-count scan by default. A user-supplied similarity graph is also supported.
gseg2(x = NULL, dissimilarity = NULL, statistics = "m",
l0 = NULL, l1 = NULL, pval.appr = TRUE, skew.corr = TRUE,
pval.perm = FALSE, B = 100, k = NULL, n = NULL, E = NULL)
x |
A numeric matrix with observations in rows. For compatibility, the first positional argument may instead be the number of observations when the second positional argument is an edge matrix. |
dissimilarity |
A square symmetric dissimilarity matrix or a |
statistics |
The scan statistic or statistics to compute. The default
|
l0 |
Minimum candidate interval length. The default is |
l1 |
Maximum candidate interval length. The default is |
pval.appr |
Whether to calculate the analytic p-value approximation. This approximation requires at least nine observations. |
skew.corr |
Whether to include the skewness correction in the analytic p-value approximation. |
pval.perm |
Whether to calculate a permutation p-value. |
B |
Number of permutations. |
k |
Number of MST layers for a data-level call. The default is
|
n |
Number of observations in a graph-level call. Both named and positional legacy graph arguments are supported. |
E |
Two-column edge matrix in a graph-level call. Do not supply
|
An interval with boundaries (i, j) contains observations
i + 1, ..., j. When there are r tied maximizing intervals,
tauhat (or tauhat_a/tauhat_u) retains the earlier
layout: its first r entries are the left boundaries and its last
r entries are the corresponding right boundaries. All returned
intervals satisfy the requested length range after the documented endpoint
adjustments. The analytic approximation requires a nonzero length range;
use permutation calibration for a single permitted interval length.
A list with scanZ and any requested p-values. Each requested component
of scanZ contains the estimated interval tauhat, maximum scan
statistic Zmax, and scan surface. Data-level calls additionally return
the constructed graph and k.
Analytic integrations are checked for convergence and finite probability
outputs in [0,1]. An unavailable approximation raises an error rather
than returning an invalid probability. Setting pval.appr = FALSE allows
justified permutation calibration to be used instead. Scan components must be
well-defined on the requested domain; undefined components are not replaced
by zero.
gseg1, gseg2_graph,
gseg2_discrete, gseg_kmst
set.seed(2)
x <- matrix(rnorm(80), nrow = 20)
x[8:13, ] <- x[8:13, ] + 1
# Main interface: build the default k-MST and report MET.
ans <- gseg2(x, pval.appr = FALSE)
names(ans$scanZ)
ans$k
# Earlier graph-level calls remain supported.
ans.graph <- gseg2(nrow(x), ans$graph, pval.appr = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.