move.HMM.viterbi: Assign states using the Viterbi algorithm

Description Usage Arguments Value Examples

View source: R/move.HMM.viterbi.R

Description

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.

Usage

1

Arguments

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.

Value

A vector of state assignments.

Examples

 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)

benaug/move.HMM documentation built on Jan. 23, 2022, 4:29 a.m.