# NOT RUN {
## Gamma or Exponential
### because we do not supply "priors" as an input it fits an Exponetial distribution
# }
# NOT RUN {
data(NHMMdata)
attach(NHMMdata)
my.hmm1=HMM(y=ygamma, K=3, iters=100, burnin=10, emdist="gamma",
nmix=3, delta=TRUE)
OBIC(my.hmm1)
zz=Oz(my.hmm1) #compare with the truth zgamma
qq=OQQ(my.hmm1)
pp=OWcoef(my.hmm1,FALSE)
tt=Oemparams(my.hmm1,FALSE)
## Normal
my.hmm2=HMM(y=ynormal, subseq=100, K=3, iters=100, burnin=10,
emdist="normal", nmix=2, delta=FALSE)
OBIC(my.hmm2)
## Poisson
my.hmm3=HMM(y=ypoisson, K=3, iters=100, burnin=10, emdist="poisson",
nmix=2, delta=FALSE)
OBIC(my.hmm3)
## Predictive estimation - make 15 predictive data sets (new X) and 20 replicate data sets (same X)
filelocation="C:\\Users\\iamrandom\\Desktop\\here\\"
my.hmm5=HMM(y=ygamma, W=tW, K=3, iters=100, burnin=10,
emdist="gamma", nmix=3, delta=TRUE,
outdir=filelocation, pT=200, yrep=20, Wp=Wp1, ypred=15)
OBIC(my.hmm5)
pp=OWcoef(my.hmm5,filelocation)
## Gamma with fixed first variables nmix=2
nmix=2; K=3; J=dim(ygamma)[2]
prior1=array(1,dim=c(5,nmix,K,J)); prior1[1,1,,]=1; prior1[1,2,,]=2; prior1[2,,,]=NA
my.hmm6=HMM(y=ygamma, priors=prior1, K=3, iters=100, burnin=10,
emdist="gamma", nmix=2, delta=TRUE)
OBIC(my.hmm6)
Oemparams(my.hmm6)
### my.nhmm7 (K=3) (yhold is the last 10% of the data)
filelocation="C:\\Users\\iamrandom\\Desktop\\here\\"
my.hmm7=HMM(y=ygamma[1:1800,], W=array(tW[,1:1800,],
dim=c(1,1800,15)), K=3, iters=50, burnin=10,
emdist="gamma", nmix=3, delta=TRUE, outdir=filelocation,
ymiss=TRUE, yrep=10, pT=200,
Wp=array(tW[,1801:2000,],dim=c(1,200,15)), ypred=10,
yhold=ygamma[1801:2000,])
OBIC(my.hmm7)
# run it with K=3 and then K=1 and compare using both BIC and PLS
# }
Run the code above in your browser using DataLab