"node not found" issue

Help
pluvialis
2014-02-11
2014-02-12
  • pluvialis

    pluvialis - 2014-02-11

    Dear all;

    I'm getting a "node not found" error for two of my monitored variables when using either coda.samples or jags.samples. From what I could see in previous threads there's no universal solution to the issue. Any idea?

    Model and R script below

    1/Model

    model{
    
    for(i in 1:nanimal){
    tauepst[i]<-taueps[Spani[i]]
    taugpst[i]<-taugps[Spani[i]]
    tauexpt[i]<-tauexp[Spani[i]]
    
    for(t in 2:ntemps){
    defec[i,t] ~ dbin(pdef[i,t],1)
    logit(pdef[i,t]) <- adef[Spani[i]] + bdef[Spani[i]]*(temps[t]-meant) + cdef[Spani[i]]*(temps[t]*temps[t]-meant2)
    }
    
    for(j in 1:nplante){
    Nt[i,j,1] ~ dpois(Ntot[i,j])
    Y.rep[i,1,j] <- 0
    G.rep[i,1,j] <- 0
    
    for(t in 2:ntemps){
    Nt[i,j,t] <- Nt[i,j,t-1] - Nf[i,t,j]
    Nf[i,t,j] ~ dbin(pexeff[i,j,t],Nt[i,j,t-1])
    pexeff[i,j,t]<-pex[i,j,t]*defec[i,t]
    logit(pex[i,j,t]) <- aex[Spani[i],j] + bex[Spani[i],j]*(temps[t]-meant) + cex[Spani[i],j]*(temps[t]*temps[t]-meant2)+ranefex[i,j,t]
    ranefex[i,j,t] ~ dnorm(mueps,tauexpt[i])
    
    eps[i,t,j] ~ dnorm(mueps,tauepst[i])
    logit(lambda[i,t,j]) <- logit(poidsRfeces[i,t])
    Nfc[i,t,j] ~ dbin(lambda[i,t,j],Nf[i,t,j])
    logit(lambdabis[i,t,j]) <- logit(pviz[Spani[i],j])+eps[i,t,j]
    Y[i,t,j] ~ dbin(lambdabis[i,t,j],Nfc[i,t,j])
    resteNf[i,t,j]<-Nf[i,t,j]-Nfc[i,t,j]
    
    gps[i,t,j] ~ dnorm(mueps,taugpst[i])
    logit(pgerm[i,t,j]) <- agerm[Spani[i],j] + bgerm[Spani[i],j]*(temps[t]-meant)
    logit(pg[i,t,j]) <- logit(poidsRgerm[i,t]/(1-poidsRfeces[i,t])*pgerm[i,t,j])+gps[i,t,j]
    G[i,t,j] ~ dbin(pg[i,t,j],resteNf[i,t,j])
    
          } # t
        } # j
      } # i
    
    #------#
    # priors
    #------#
      for(i in 1:3){
          adef[i]~dnorm(0,0.0001)
          bdef[i]~dnorm(0,0.0001)
          cdef[i]~dnorm(0,0.0001)
      taueps[i]<-1/(sigeps[i]*sigeps[i])
      sigeps[i]~dunif(0,100)
    
      tauexp[i]<-1/(sigexp[i]*sigexp[i])
      sigexp[i]~dunif(0,100)
    
      taugps[i]<-1/(siggps[i]*siggps[i])
      siggps[i]~dunif(0,100)
    
      for(j in 1:nplante){
          agerm[i,j]~dnorm(0,0.0001)
          bgerm[i,j]~dnorm(0,0.0001)
    
         pviz[i,j]~dunif(0,1)
    
          aex[i,j]~dnorm(0,0.0001)
          bex[i,j]~dnorm(0,0.0001)
          cex[i,j]~dnorm(0,0.0001)
        } # j
      } # i
    
       mueps<-0
    
    } # model
    

    2/R script (note: chain length restricted for trial purpose, normally around 1000 000 each)

    # data list
    datax=list(Y=ifelse(is.na(Y),0,Y),  
                G=ifelse(is.na(Yg),0,Yg),  
                poidstot=as.matrix((poidstot)),
                defec=as.matrix(defec),
                poidsRfeces=as.matrix((poidsRfeces)),
                poidsRgerm=as.matrix((poidsRgerm)), 
                temps=temps,
                meant=mean(temps),
                meant2=mean(temps^2),
                nanimal=nanimal,
                nplante=nplante,
                ntemps=unlist(ntemps),
                Ntot=as.matrix(Ntot),
                Spani=Spani)
    
    # inits
     inits=list(aex=aex,
                bex=bex,
                cex=cex,
                agerm=aex,
                bgerm=bex,
                Nt=Nt,
                Nf=Nf,
                Nfc=Nfc,
                Nfg=Nfg,
                sigexp=rep(0.1,3),
                sigeps=rep(0.1,3),
                siggps=rep(0.1,3)  
                )
    
    # run the model
    
    model=jags.model(file="mod16.r",data=datax,inits=inits,n.chains=3,n.adapt=1000,quiet=FALSE)
    
    update(model,n.iter=1000)
    
    chain5jag=coda.samples(model,c("adef","bdef","cdef","Nf","aex","bex","cex","ranefex","pviz","lambdabis","agerm","bgerm","pg","taueps","tauexp","taugps","Y.rep","G.rep"),n.iter=100,thin=2)
    

    3/ error message (sorry for the odd danish lookout)

    Fejl i jags.samples(model, "Nf", n.iter = 20, thin = 2) : 
      No valid monitors set
    In addition: Advarselsbesked:
    In jags.samples(model, "Nf", n.iter = 20, thin = 2) :
      Failed to set trace monitor for Nf
    Node not found
    

    Hopefully the information provided above will be enough, otherwise please tell me what to add.
    Thanks a lot in advance;

    All the best

    JY Barnagaud

     
  • Martyn Plummer

    Martyn Plummer - 2014-02-12

    JAGS can only monitor a completely defined Node array. Since you have not defined Nf[i,1,j], you can't monitor Nf. Just add

    Nf[i,1,j] <- 0
    

    under the definitions of Y.rep[i,1,j] and G.rep[i,1,j].

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks