我用rjags实现了LDA模型。我成功地获得了最终样本:
jags <- jags.model('../lda_jags.bug',
data = data,
n.chains = 1,
n.adapt = 100)
update(jags, 2000)
samples <- jags.samples(jags,
c('theta', 'phi', 'z'),
1000)
现在,我可以使用samples$theta
或samples$phi
来获取theta
和phi
的结果。但我怎么知道抽样需要多长时间?谢谢!
答案 0 :(得分:1)
正如@ eipi10所述,您可以在update()调用周围使用system.time()来计算R中的进程。或者,您可以使用runjags包来打印更新模型所花费的(总)时间,包括所有以前调用extend.jags:
library('runjags')
results <- run.jags('../lda_jags.bug', monitor = c('theta', 'phi', 'z'),
data = data, n.chains = 1, adapt = 100, burnin = 2000, sample = 1000)
results
# or:
jags <- jags.model('../lda_jags.bug',
data = data,
n.chains = 1,
n.adapt = 0)
runjags <- as.runjags(jags, monitor = c('theta', 'phi', 'z'))
results <- extend.jags(runjags, adapt = 100, burnin = 2000, sample = 1000)
results
results <- extend.jags(runjags, sample = 1000)
results