Clever?
and what about something stupid: using a double index t=1:T for all the
variables in the inner loop? this should do the job, at the cost of a
lot of space...
simon
Dr. S.H. Heisterkamp
Department of Clinical Epidemiology and Biostatistics
Academic Medical Center, University of Amsterdam
PO BOX 22700, 1100 DE AMSTERDAM, The Netherlands
voice: +31-20-5668520
fax : +31-20-6912683
> -----Original Message-----
> From: David Spiegelhalter [SMTP:[log in to unmask]]
> Sent: Friday, May 19, 2000 11:39 AM
> To: [log in to unmask]
> Subject: Re: Running simulations in WinBUGS
>
> Dear Bill and others
>
> You asked about running simulations in WinBUGS, and Finn Krogstad made
> a clever suggestion below (with some syntax corrections)
>
> 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.sim/(2*pi),.5)/something.
> big
> }
> something.big <- 2000
> pi <- 3.14159
> }
> # inits
> list(mu.sim=0,tau.sim=1)
> # data
> list(N=10)
>
> Putting the above inside another loop, say of size T, looks as if it
> will do T repetitions of an MCMC run with simulated data.
>
> Unfortunately, as Finn realised, this does not work. At each iteration
> the simulated values for y are not just generated from their prior,
> but
> are influenced by the current values of mu.sim and tau.sim. If you
> try
> running the above code, you will find the marginal distributions of
> the y's is too narrow, and so tau.sim is much larger than tau. This
> is
> similar to the `feedback' issue in measurement error problems
> discussed,
> for example, in the Classic BUGS manual.
>
> We are currently working on two developments that may help:
>
> 1) a batch version of WinBUGS
>
> 2) a facility for `cutting' the feedback in a graphical model. Thus
> if
> y was `cut' from the remainder of the model, it would only be sampled
> from its prior.
>
> Sorry, but currently you need to do multiple runs (unless someone can
> think
> of something clever!)
>
> David
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|