# NOT RUN {
## Specify hidden markov models. The x[i]'s are unobserved, the
## y[i]'s can be observed.
yn <- c("yes","no")
## Specify p(x0)
x.0 <- cptable(~x0, values=c(1,1), levels=yn)
## Specify transition density
x.x <- cptable(~x[i]|x[i-1], values=c(1,99,2,98),levels=yn)
## Specify emissiob density
y.x <- cptable(~y[i]|x[i], values=c(1,99,2,98),levels=yn)
## The pattern to be repeated
pp <- list(x.x, y.x)
## Repeat pattern and create network
ppp <- repeatPattern(pp, instances=1:10)
qqq <- compileCPT(c(list(x.0),ppp))
rrr <- grain(qqq)
# }
Run the code above in your browser using DataLab