Menu

Lower and upper limits of deterministic node

Help
2014-03-03
2014-03-03
  • Luis Baroja

    Luis Baroja - 2014-03-03

    Hi everyone,
    I'm trying to truncate deterministic node theta.t to ensure its values lie between 0 and 1.
    I've tried to solve the issue by employing T(0,1) function at the end of line 6, which doesn't work, and I'm not sure how to use ~dinterval() to address this particular problem.
    Here the code:

    model{
      # PRIORS
      alpha~dunif(0,1)
      beta~dunif(0,1)
      # Deterministic Node
      for(j in 1:n.intervals){
        theta.t[j]<-exp(-alpha*retention.intervals[j])+beta
      }
      # DATA
      for(i in 1:n.participants){
        for(j in 1:n.intervals){
          k[i,j]~dbin(theta.t[j],18)
        }
      }
      }
    

    Thanks in advance!

     
  • Martyn Plummer

    Martyn Plummer - 2014-03-03

    You can either add a data step (as below) or supply these values with the data

    data {
       breaks[1] <- 0
       breaks[2] <- 1
       for (j in 1:n.intervals) {
           trunc[j] <- 1
       }
    }
    model {
       ...
    }
    

    Then in the model you add

        for(j in 1:n.intervals) {
            trunc[j] ~ dinterval(theta.t[j], breaks)
        }
    

    This adds the information that theta.t[j] is observed to lie between breaks[1] (0) and breaks[2] (1).

    Note that formally this is censoring ([i]a posteriori[/i] constraint) not truncation ([i]a priori[/i] constraint). Happily in your example neither alpha nor beta have unobserved parents, so censoring and truncation are equivalent. You should not do this in a model where you are trying to learn about hyper-parameters of alpha and beta.

     

Log in to post a comment.