Print

Print


Re: [BUGS] generating replicates from zeros trick

Hi Dipankar,

I provide an example, showing how to generate replicates using zeros trick.

Hope this helps.

Zane


model {
        for (i in 1:8) {
                zeros[i] <- 0                                           # trick using zeros
                zeros[i] ~ dpois(phi[i])                        # likelihood is exp(-phi[i])
                phi[i] <- -0.5 * log(tau[1]) + 0.5 * tau[1] * pow((x[i] - mu[1]) , 2)                   # -log(likelihood)

                x[i] ~ dnorm(0, 0.000001)                       # very vague normal prior on x's
        }
       
        for (i in 1:8) {                                                                # check using normal distribution

                x.rep[i] ~ dnorm(mu[2], tau[2])
        }
        for (k in 1:2) {
                mu[k] ~ dnorm(0, 0.000001)
                tau[k] ~ dgamma(0.001, 0.0001)
        }
}

Data:
list(x = c(-1, -0.3, 0.1, 0.2, 0.7, 1.2, 1.7, NA), x.rep=c(-1, -0.3, 0.1, 0.2, 0.7, 1.2, 1.7, NA))

Initial values:
list(tau = c(1, 1), mu = c(0, 0), x = c(NA, NA, NA, NA, NA, NA, NA, 0))

--------------------------------
Thank you Pablo for this solution, but how would I generate "replicates" of the first element in your data-vector (i.e. 2) coming from the posterior predictive distribution?

Dipankar

On Thu, Feb 2, 2012 at 10:16 AM, Dr. Pablo E. Verde <[log in to unmask]> wrote:

------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list

------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list