Closed maforinw closed 5 years ago
Hi @maforinw Thanks for your question. There are a couple of small differences between the HMM objects, the main one being that the transitions from the begin state and to the end state are included in the first row and column of the transition matrix, respectively. In your case the end state is not modeled, so the first column will just be zeros. Also, the states and residues (symbols) are included as the row names and column names of the emission matrix, respectively. This means there are only two objects in the list, the transition matrix (A) and the emission matrix (E). So you can initialize and plot your model like this:
states <- c("Begin", "feeding", "inactive", "exploring", "others", "moving", "grooming")
residues <- paste0(states[2:7],"E")
transProbs <- rbind(startProbs, transProbs)
transProbs <- cbind(0, transProbs)
dimnames(transProbs) <- list(from = states, to = states)
residues <- c("F", "I", "E", "O", "M", "G") # abbreviated for plotting
dimnames(emissionProbs) <- list(states = states[-1], residues = residues)
model <- list(A = transProbs, E = emissionProbs)
class(model) <- "HMM"
plot(model, begin = TRUE)
Thank you for taking the time to tackle this question.
Hi Shaun,
I recently came across HMM to improve outputs from ensemble learners in order to infer animal behaviours. I am particularly interested in your 'aphid' package because I would like to use a list of different sequences (e.g. obtained from direct observations) for parameter tuning (using the Baum-Welch algorithm) before using Viterbi algorithm in a routine process.
The first step is to initialize the parameters of the HMM :
By using the R package HMM, each parameter initialization is quite obvious. The final object returns a list of 5 elements containing all the parameters.
library(HMM)
symbols = paste0(levelBehav[2:7],"E")
startProbs = c(0.040, 0.407, 0.077, 0.063, 0.360, 0.053)
hmm<-initHMM(levelBehav[2:7], symbols, startProbs, transProbs, emissionProbs)
hmm
So my question is how porting objects between the HMM and aphid packages ? Or, how initializing all the parameters, including initial states probabilities in aphid (given that 'residues' means 'symbols') ?
Thank you.