J <- 3
Pi <- matrix(c(0.0, 0.6, 0.4,
0.5, 0.0, 0.5,
0.3, 0.7, 0.0), nrow = J, byrow = TRUE)
obspar <- list(
mean = c(4, 2, 6),
sd = c(1, 1, 2)
)
dwellpar <- list(
lambda = c(3, 5, 4)
)
# Simulate HSMM data
sim <- generateHSMM(n = 1000, J = J, obsdist = "norm",
dwelldist = "pois", obspar = obspar,
dwellpar = dwellpar, Pi = Pi)
# Fit HSMM using the true parameters
HSMM_true <- findmleHSMM(x = sim$x, J = J, M = 100,
obsdist = "norm", dwelldist = "pois",
obspar = obspar, dwellpar = dwellpar,
Pi = Pi)
# Decode states using globaldecodeHSMM
states <- globaldecodeHSMM(x = sim$x, M = 100, HSMM = HSMM_true,
obsdist = "norm", dwelldist = "pois")
head(states)
Run the code above in your browser using DataLab