View source: R/canonical-interface.R
| gseg1 | R Documentation |
Detects a single distributional change in 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.
gseg1(x = NULL, dissimilarity = NULL, statistics = "m",
n0 = NULL, n1 = 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
|
n0 |
First candidate change-point location. The default is
|
n1 |
Last candidate change-point location. 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
|
The requested statistic must have positive permutation variance at each
candidate location. Graphs for which a candidate score is undefined are
rejected rather than silently omitted. For a single candidate location,
set pval.appr = FALSE and use permutation calibration instead of
the continuous-range analytic scan approximation.
A list with scanZ and any requested p-values. Each requested component
of scanZ contains the estimated change-point tauhat, maximum
scan statistic Zmax, and scan path. 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.
gseg2, gseg1_graph,
gseg1_discrete, gseg_kmst
set.seed(1)
x <- rbind(matrix(rnorm(40), 10), matrix(rnorm(40, 1), 10))
# Main interface: build the default k-MST and report MET.
ans <- gseg1(x, pval.appr = FALSE)
names(ans$scanZ)
ans$k
# A dissimilarity matrix may be supplied instead.
ans.d <- gseg1(dissimilarity = as.matrix(dist(x)), pval.appr = FALSE)
# Request GET explicitly.
ans.get <- gseg1(x, statistics = "g", pval.appr = FALSE)
# Earlier graph-level calls remain supported.
ans.graph <- gseg1(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.