| plot.net_markov_order | R Documentation |
Two-panel professional visualization:
Panel A: log-likelihood, AIC, BIC across tested orders with the selected order highlighted (both the permutation-selected order and the BIC-minimizing order are marked).
Panel B: permutation null density per order with the observed
G^2 as a vertical marker; colored by rejection at
alpha.
Uses the Okabe-Ito colorblind-safe palette.
## S3 method for class 'net_markov_order'
plot(x, panel = c("both", "ic", "permutation"), combined = TRUE, ...)
x |
A |
panel |
Which panel(s) to render: |
combined |
When |
... |
Ignored. |
A ggplot (single panel); for panel = "both", either a
gridExtra gtable (when gridExtra is installed) or a
named list of two ggplots (ic, permutation) drawn
side-by-side and returned invisibly.
# First-order Markov data: test should select order 1
set.seed(1)
states <- letters[1:4]
tm <- matrix(runif(16), 4, 4, dimnames = list(states, states))
tm <- tm / rowSums(tm)
seqs <- lapply(1:30, function(.) {
s <- character(50); s[1] <- sample(states, 1)
for (i in 2:50) s[i] <- sample(states, 1, prob = tm[s[i - 1], ])
s
})
res <- markov_order_test(seqs, max_order = 3, n_perm = 300, seed = 1)
res$optimal_order
summary(res)
plot(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.