winbugs - JAGS - hierarchical model comparison not jumping between models even with pseudopriors -


i'm using hierarchical modelling framework described kruschke set comparison between 2 models in jags. idea in framework run , compare multiple versions of model, specifying each version 1 level of categorical variable. posterior distribution of categorical variable can interpreted relative probability of various models.

in code below, i'm comparing 2 models. models identical in form. each has single parameter needs estimated, me. can seen, models differ in priors. both priors distributed beta distributions have mode of 0.5. however, prior distribution model 2 more concentrated. note i've used pseudo priors had hoped keep chains getting stuck on 1 of models. model seems stuck anyway.

here model:

 model {    m ~ dcat( mpriorprob[] )   mpriorprob[1] <- .5   mpriorprob[2] <- .5    omegam1[1] <- 0.5      #true prior   omegam1[2] <- 0.5      #psuedo prior    kappam1[1] <- 3        #true prior model 1   kappam1[2] <- 5        #puedo prior model 1    omegam2[1] <- 0.5      #psuedo prior   omegam2[2] <- 0.5      #true prior   kappam2[1] <- 5        #puedo  prior model 2   kappam2[2] <- 10        #true prior model 2    ( s in 1:nsubj ) {      me1[s] ~ dbeta(omegam1[m]*(kappam1[m]-2)+1 , (1-omegam1[m])*(kappam1[m]-2)+1 )     me2[s] ~ dbeta(omegam2[m]*(kappam2[m]-2)+1 , (1-omegam2[m])*(kappam2[m]-2)+1 )      me[s] <- equals(m,1)*me1[s] + equals(m,2)*me2[s]      z[s] ~ dbin( me[s] , n[s] )    } } 

here r code relevant data:

datalist = list(   z = c(81, 59, 36, 18, 28, 59, 63, 57, 42, 28, 47, 55, 38,          30, 22, 32, 31, 30, 32, 33, 32, 26, 13, 33, 30),    n = rep(96, 25),   nsubj = 25 ) 

when run model, mcmc spends every single iteration @ m = 1, , never jumps on m = 2. i've tried lots of different combinations of priors , pseudo priors, , can't seem find combination in mcmc consider m = 2. i've tried specifying identical priors , pseudo priors models 1 , 2, no help. in situation, expect mcmc jump between models, spending half time considering 1 model, , half time considering other. however, jags still spent whole time @ m = 1. i've run chains long 6000 iterations, should more long enough simple model this.

i appreciate if has thoughts on how resolve issue.

cheers, tim

i haven't been able figure out, thought else works on might appreciate following code, reproduce problem start-to-finish r rjags (must have jags installed).

note since there 2 competing models in example, changed m ~ dcat() m ~ dbern(), , replaced m m+1 everywhere else in code. hoped might ameliorate behavior, did not. note if specify initial value m, stays stuck @ value regardless of value pick, m fails updated (instead of getting weirdly attracted 1 model or other). head-scratcher me; worth posting martyn's eyes @ http://sourceforge.net/p/mcmc-jags/discussion/

library(rjags) load.module('glm')  datalist = list(   z = c(81, 59, 36, 18, 28, 59, 63, 57, 42, 28, 47, 55, 38,          30, 22, 32, 31, 30, 32, 33, 32, 26, 13, 33, 30),    n = rep(96, 25),   nsubj = 25 )  sink("mymodel.txt") cat("model {    m ~ dbern(.5)    omegam1[1] <- 0.5      #true prior   omegam1[2] <- 0.5      #psuedo prior    kappam1[1] <- 3        #true prior model 1   kappam1[2] <- 5        #puedo prior model 1    omegam2[1] <- 0.5      #psuedo prior   omegam2[2] <- 0.5      #true prior   kappam2[1] <- 5        #puedo  prior model 2   kappam2[2] <- 10        #true prior model 2      ( s in 1:nsubj ) {      me1[s] ~ dbeta(omegam1[m+1]*(kappam1[m+1]-2)+1 , (1-omegam1[m+1])*(kappam1[m+1]-2)+1 )     me2[s] ~ dbeta(omegam2[m+1]*(kappam2[m+1]-2)+1 , (1-omegam2[m+1])*(kappam2[m+1]-2)+1 )       z[s] ~ dbin( (1-m)*me1[s] + m*me2[s] , n[s] )      }     }     ", fill=true) sink() inits <- function(){list(m=0)}  params <- c("m")  nc <- 1 n.adapt <-100 n.burn <- 200 n.iter <- 5000 thin <- 1 mymodel <- jags.model('mymodel.txt', data = datalist, inits=inits, n.chains=nc, n.adapt=n.adapt) update(mymodel, n.burn) mymodel_samples <- coda.samples(mymodel,params,n.iter=n.iter, thin=thin) summary(mymodel_samples) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -