Description Usage Arguments Value Examples
View source: R/move.HMM.viterbi.R
This function, modified from Zucchini and MacDonald (2009), assigns states to observations using the Viterbi algorithm. It takes as input a move.HMM object and an optional vector containing the starting state probabilities.
1 | move.HMM.viterbi(move.HMM, delta = NULL)
|
move.HMM |
A move.HMM object containing a fitted HMM model. |
delta |
An optional vector of starting state probabilities. If no vector is supplied, the stationary distribution is used. |
A vector of state assignments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
#2 states, 2 dist-lognorm, wrapped normal
lmean=c(-3,-1) #meanlog parameters
sd=c(1,1) #sdlog parameters
rho<-c(0.2,0.3) # wrapped normal concentration parameters
mu<-c(pi,0) # wrapped normal mean parameters
gamma0=matrix(c(0.6,0.4,0.2,0.8),byrow=T,nrow=2)
dists=c("lognormal","wrpnorm")
nstates=2
turn=c(1,2)
params=vector("list",3)
params[[1]]=gamma0
params[[2]]=cbind(lmean,sd)
params[[3]]=cbind(mu,rho)
obs=move.HMM.simulate(dists,params,1000)$obs
turn=c(1,2)
move.HMM=move.HMM.mle(obs,dists,params,stepm=35,iterlim=100,turn=turn)
#get Viterbi state assignments
move.HMM.viterbi(move.HMM)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.