The ones[i] example (right after the list of distributions in the
manual) allows:
1. metropolis simulation from general distributions
2. an exception to the multiple definition prohibition
In effect we are using this exception to both simulate and infer mu1,tau1
from the same nodes y[]
mu,tau -> y[] <- mu1,tau1 -> y1[] <- mu2,tau2 -> ...
Note that y[] is influenced by both mu,tau and mu1,tau1 and thus does not
have the distribution dnorm(mu,tau) anymore. My appologies to everyone
for having posted this without having thought it through.
Finn Krogstad
U. Washington, Forest Engineering
http://students.washington.edu/fkrogsta
On Thu, 18 May 2000, Ziad Elmously wrote:
> Finn,
>
> What is the purpose of setting ones[i] to 1 and then simulating them from a
> Bernoulli distribution, i.e.,
>
> ones[i] <- 1
> ones[i] ~dbern(p[i])
>
> Besides, you have a loop through N, the number of observations. Where is
> the loop through the simulations?
>
> Sincerely,
>
> Ziad Elmously
> Research and Development
> Taylor Nelson SOFRES Intersearch
> [log in to unmask]
>
> > -----Original Message-----
> > From: Finn Krogstad [SMTP:[log in to unmask]]
> > Sent: Thursday, May 18, 2000 3:54 PM
> > To: William Simpson
> > Cc: [log in to unmask]
> > Subject: Re: Running simulations in WinBUGS
> >
> > A question after my own heart. The answer is yes (see code below).
> >
> > Finn Krogstad
> > U. Washington, Forest Engineering
> > http://students.washington.edu/fkrogsta
> >
> > model;{
> > mu <-0
> > tau <-1
> > mu.sim~dnorm(0,.001)
> > tau.sim~dexp(1)
> > for (i in 1:N){
> > y[i] ~ dnorm(mu,tau)
> > ones[i] <- 1
> > ones[i] ~dbern(p[i])
> > p[i] <-
> > exp(-pow(y[i]-mu.sim,2)/(tau.sim/2))*pow(tau/(2*pi),2)/something.big
> > y.sim[i] ~ dnorm(mu.sim,tau.sim)
> > # and so on
> > }
> > something.big <- 2000
> > pi <- 3.14159
> > }
> > # inits
> > list(mu.sim=0,tau.sim=1)
> > # data
> > list(N=10)
> >
> >
> >
> > On Thu, 18 May 2000, William Simpson wrote:
> >
> > > If I create a model in WinBUGS, specify the parameters, and don't enter
> > > data, then WinBUGS will simulate data, e.g.
> > >
> > > model
> > > {
> > > mu <- 2
> > > tau <- 1
> > > for (i in 1:N) {
> > > y[i] ~ dnorm(mu,tau)
> > > }
> > > }
> > >
> > >
> > > What I'd like to do is:
> > > Simulate a set of data
> > > Run MCMC to estimate the parameters
> > > Simulate another set of data
> > > Run MCMC
> > > etc.
> > >
> > > Is there a way to specify a model that will do this? Or do I have to
> > write
> > > some kind of script/batch file to do the iterations of the simulation?
> > >
> > > Thanks,
> > > Bill Simpson
> > >
> > >
> > >
> > >
> > > ---------------------------------
> > > William Simpson
> > > Faculty Research Computing Center
> > > Harvard Business School
> > > [log in to unmask]
> > > ---------------------------------
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|