Lower and upper limits of deterministic node

  • 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:

      # PRIORS
      # Deterministic Node
      for(j in 1:n.intervals){
      # DATA
      for(i in 1:n.participants){
        for(j in 1:n.intervals){

    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.


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

Sign up for the SourceForge newsletter:

No, thanks