I am replying to the list as I this may be a common issue.
The problem is specifying a data node (ie 'response') as a logical
function. This is impossible within the BUGS program (see Section 9.1d
of the WinBUGS manual). Logical nodes are essentially just notational
conveniences to connect up stochastic nodes, and cannot be given data
or initial values.
Of course people do observe variables which are functions of other
variables, but I'm afraid you need to work out what the actual
distribution of each data-node is. In this particular case I feel
sure you could have response as Bernoulli with a probability that is a
function of other quantities (although I admit I cannot see quite what
at the moment!).
Sorry about this restriction.
David
>
> The following program is meant to illustrate a simple Bayes Net, where a
> coin flip is communicated by the parent
> to two children, and every node in a family tells the truth independently,
> but with the same prob (uniform over .7, .8. & .9).
>
> Model LyingCoinFlip
> {
> for (i in 1:nfam) {
> response1[i] <- 1 - flip - truth1[i] + 2*flip*truth1[i];
> response2[i] <- 1 - response1[i] - truth2[i] + 2*response1[i]*truth2[i];
> response3[i] <- 1 - response1[i] - truth3[i] + 2*response1[i]*truth3[i];
> truth1[i] ~ dbern (lprob);
> truth2[i] ~ dbern (lprob);
> truth3[i] ~ dbern (lprob);
> }
> lprob <- .1*x+.6;
> flip ~ dbern(cprob);
> x ~ dcat(p[1:3]);
> }
> list(cprob=.5,nfam=2,p=c(.333333,.333333,.333333))
> response1[ ] response2[ ] response3[ ]
> NA 1 1
> 1 0 1
>
> It checks out but when it compiles I get a message:
> "Multiple definitions of a node for response3 (a scalar may be defined in a
> loop)".
>
> I think I am beginning to reach my limited wits end. Can anyone tell me my
> error?
>
-------------------------------------------------------------------
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
|