Running examples in ‘hmmm-Ex.R’ failed
The error most likely occurred in:

> ### Name: hidden.emfit
> ### Title: ML estimation of a multinomial hidden Markov model
> ### Aliases: hidden.emfit
> ### Keywords: models
> 
> ### ** Examples
> data(drinks)
> y<-cbind(drinks$lemon.tea,drinks$orange.juice)
> fm<-c("l-l-l")
> fmargobs<-marg.list(fm)
> #initial values of transition matrix and obs distribution given the two latent states
> Ptr<-matrix(c(0.941, 0.199,0.059, 0.801),2,2,byrow=TRUE)
> Ptobs<-matrix(c(0.053, 0.215, 0.206, 0.001, 0.039, 0.021, 0.020, 0.176, 0.270,
+                 0.000, 0.000, 0.000, 0.048, 0.263, 0.360, 0.065, 0.053, 0.211),
+ 2,9,byrow=TRUE)
> find<-~lat+lat*tea+lat*juice   # lat is the latent variable
> model.obsf<-hmmm.model(marg=fmargobs,
+ lev=c(2,3,3),names=c("lat","tea","juice"),formula=find)
> 
> # model of independent observed variables given the latent states
> modelind<-hidden.emfit(y,model.obsf,y.eps=0.01,maxit=10,maxiter=2500,
+ old.tran.p=Ptr,bb=Ptobs)
> print(modelind,printflag=TRUE)

LOGLIK OF THE HIDDEN MODEL:  Loglik =  -507.0353

SUMMARY of MODEL: observation model   
 (df= 8 )

       inter.        marg.         type STRATA_1  
link1  lat           lat,tea,juice l    -17.013182
link2  tea           lat,tea,juice l    1.657854  
link3  tea           lat,tea,juice l    0.185256  
link4  juice         lat,tea,juice l    -2.029788 
link5  juice         lat,tea,juice l    2.032803  
link6  lat.tea       lat,tea,juice ll   -0.271048 
link7  lat.tea       lat,tea,juice ll   0.241425  
link8  lat.juice     lat,tea,juice ll   18.257466 
link9  lat.juice     lat,tea,juice ll   -2.847935 
link10 tea.juice     lat,tea,juice ll   0         
link11 tea.juice     lat,tea,juice ll   0         
link12 tea.juice     lat,tea,juice ll   0         
link13 tea.juice     lat,tea,juice ll   0         
link14 lat.tea.juice lat,tea,juice lll  0         
link15 lat.tea.juice lat,tea,juice lll  0         
link16 lat.tea.juice lat,tea,juice lll  0         
link17 lat.tea.juice lat,tea,juice lll  0         
  effects relating  to  latent variables only, if printed , 
 must not be considered 

SUMMARY of MODEL: latent model
(df= 0 )

      inter.         marg.          type STRATA_1 
link1 laglat_1       laglat_1       l    -1.264347
link2 lat_1          lat_1,laglat_1 l    -2.802837
link3 lat_1.laglat_1 lat_1,laglat_1 ll   4.166976 
  effects relating  to the lagged latent variables only, if printed 
 must not be considered 
> 
> #alternative definition based on hmmm.model.X
> f<-list(tea=~tea*lat,juice=~juice*lat,tea.juice="zero")
> model.obsfX<-hmmm.model.X(marg=marg.list(c("l-l")),names=c("tea","juice"),
+ fnames=c("lat"),lev=c(3,3),strata=c(2))
Error in formula.character(object, env = baseenv()) : 
  invalid formula: "tea=~tea*lat"
Calls: hmmm.model.X ... model.matrix -> as.formula -> formula -> formula.character
Execution halted