# NOT RUN {
set.seed(12933)
nsubj <- 10
ns <- 2000
ylist <- vector(mode="list",length=nsubj)
xlist <- vector(mode="list",length=nsubj)
timelist <- vector(mode="list",length=nsubj)
priorparm <- 0
tpmparm <- c(-2,0.1,-2,-0.2)
zeroindex <- c(1,0)
zeroparm <- c(0,0.5)
emitparm <- c(2,0.2,3,0.3)
workparm <- NULL
for(n in 1:nsubj){
xlist[[n]] <- matrix(rep(c(0,1),rep(1000,2)),nrow=2000,ncol=1)
timeindex <- rep(1,2000)
for(i in 2:2000) timeindex[i] <- timeindex[i-1] + sample(1:4,1)
timelist[[n]] <- timeindex
workparm <- rbind(workparm,c(priorparm,tpmparm,zeroparm,emitparm))
result <- hmmsim3.cont(workparm,2,2000,zeroindex,x=xlist[[n]],timeindex=timeindex)
ylist[[n]] <- result$series
}
####
M <- 2
priorclust <- c(rep(1,5),rep(2,5))
tpmclust <- c(rep(1,5),rep(2,5))
tpmslopeclust <- c(rep(1,5),rep(2,5))
zeroclust <- NULL
emitclust <- NULL
slopeclust <- rep(1,10)
group <- vector(mode="list",length=2)
group[[1]] <- 1:5; group[[2]] <- 6:10
###
time <- proc.time()
result <- dist_learn3(ylist, xlist, timelist, 2,workparm,
NULL, rho=1, priorclust,tpmclust,tpmslopeclust,
emitclust,zeroclust,slopeclust,group,ncores=1,
maxit=20, tol=1e-4, method="CG",print=TRUE)
proc.time() - time
# }
Run the code above in your browser using DataLab