Forward and Backward Probabilities for Hidden Markov Model
The forward_backward
function computes scaled forward and backward probabilities of a hidden Markov model.
forward_backward(model, forward_only = FALSE, log_space = FALSE, threads = 1)
model |
Object of class |
forward_only |
If |
log_space |
Compute forward and backward probabilities in logarithmic scale instead of scaling.
The default is |
threads |
Number of threads used in parallel computing. The default is 1. |
List with components
forward_probs |
If |
backward_probs |
Scaled backward probabilities ( |
scaling_factors |
Sum of non-scaled forward probabilities at each time point.
Only computed if |
In case of multiple observations, these are computed independently for each sequence.
# Load a pre-defined MHMM data("mhmm_biofam") # Compute forward and backward probabilities fb <- forward_backward(mhmm_biofam) # The most probable hidden state at time t # given the observations up to time t for the first subject: apply(fb$forward_probs[, , 1], 2, which.max)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.