Kenny
Kenny

Reputation: 361

jags: coda package, how to select multiple parameters

I used r2jags to run jags and do the sampling. Then, I used coda package to check convergence. As I have many subjects and many parameters, I would need to manually type them as the codes below. Are there any easier approaches that I can for example, choose gamma for every subject? Or, just select gamma from subject 1 to 10 without typing them manually?

codaSamples = as.mcmc.list(samples$BUGSoutput)

acfplot(codaSamples[,c('gamma[1]','gamma[2]','gamma[3]','gamma[4]','gamma[5]','gamma[6]',
                         'gamma[7]','gamma[8]','gamma[9]','gamma[10]','gamma[11]','gamma[12]',
                         'gamma[13]','gamma[14]','gamma[15]')],lag.max=1000)

Upvotes: 0

Views: 174

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226577

A reproducible example would be nice but presumably

cols <- sprintf("gamma[%d]",1:15); codaSamples[,cols]

would do what you need? Or

cols <- grep("^gamma",colnames(codaSamples)); codaSamples[,cols]

Upvotes: 1

Related Questions