Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/hmm_functions.R
Predicts the underlying state sequence for an observed sequence newdata
given a hmmspec
model
1 2 |
object |
An object of class |
newdata |
A vector or list of observations |
method |
Prediction method (see details) |
... |
further arguments passed to or from other methods. |
If method="viterbi"
, this technique applies the Viterbi
algorithm for HMMs, producing the most likely sequence of states
given the observed data. If method="smoothed"
, then the
individually most likely (or smoothed) state sequence is produced,
along with a matrix with the respective probabilities for each
state. This function differs from predict.hmm in that it takes the
output from hmmspec ie. this is useful when users already know their
parameters and wish to make predictions.
Returns a hsmm.data
object, suitable for plotting.
newdata |
A vector or list of observations |
s |
A vector containing the reconstructed state sequence |
N |
The lengths of each sequence |
p |
A matrix where the rows represent time steps and the columns are the probability for the respective state (only produced when |
Jared O'Connell jaredoconnell@gmail.com
Rabiner, L. (1989), A tutorial on hidden Markov models and selected applications in speech recognition, Proceedings of the IEEE, 77, 257-286.
1 2 3 4 5 6 7 | J<-3
initial <- rep(1/J,J)
P <- matrix(c(.8,.5,.1,0.05,.2,.5,.15,.3,.4),nrow=J)
b <- list(mu=c(-3,0,2),sigma=c(2,1,.5))
model <- hmmspec(init=initial, trans=P, parms.emission=b,dens.emission=dnorm.hsmm)
train <- simulate(model, nsim=300, seed=1234, rand.emis=rnorm.hsmm)
mean(predict(model,train)$s!=train$s) #error rate when true model is known
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.