predict.MarkovMix {markovmix} | R Documentation |
Predict probabilities with MarkovMix object and new sequence list
Description
predict.MarkovMix
predicts probabilities with MarkovMix
object
and new sequence list. NA values are returned for sequences with no valid sub-sequences
to distinguish them from those that are truly not observed (probabilities = 0)
in the transition matrices.
Usage
## S3 method for class 'MarkovMix'
predict(object, newdata, aggregate. = TRUE, ...)
Arguments
object |
|
newdata |
Sequence list containing vectors of the same class. |
aggregate. |
Logical (1L) indicating whether probabilities
from each component should be weighted mean by component priors
( |
... |
Currently ignored for this method. |
Value
For aggregate. = TRUE
, a numeric vector of probabilities.
For aggregate. = TRUE
, a numeric matrix of probabilities
from each component.
Note
Change log:
0.1.0 Xiurui Zhu - Initiate the function.
Author(s)
Xiurui Zhu
See Also
Other MarkovMix methods:
print.MarkovMix()
Examples
# Load example MarkovMix object
data("markov_mix_ex")
# Generate a new list of sequences
set.seed(2222L)
new_maxlen <- 8L
new_seq_list <- purrr::map(
seq_len(50L),
~ sample(get_states(object = markov_mix_ex, check = FALSE),
sample.int(new_maxlen, 1L),
replace = TRUE)
)
# Predict the probabilities of sequences
predict(markov_mix_ex, newdata = new_seq_list)
# Predict the probabilities of sequences from each component
predict(markov_mix_ex, newdata = new_seq_list, aggregate. = FALSE)
[Package markovmix version 0.1.3 Index]