Hi,
Many thanks to everyone (Andrew Millard, David LeBlond, Simon Bonner, George Tomlinson, Bob O'Hara, Andrew Thomas, Nicky Best, Samu Mantyniemi, Mark Brewer,
David Spiegelhalter & Rodney Sparapani) who pointed out that I had used the dcat function incorrectly, and that the correct usage in this context would be:
model{
for(j in 1:12){
p[j] <- 1/12
}
for(i in 1:n){
x[i] ~dcat(p[])
}
}
DATA
list(n=2,x=c(1,NA))
I found that this modified version worked fine. David LeBlond also suggested that it should be possible to solve the problem using dmulti.
Best wishes, Adam
> Hi,
> I am interested in assigning a discrete uniform distribution to a
> variable x in BUGS. This is a variable for which I usually have data,
> but for which the data are sometimes missing. The variable can take
> integer values between 1 and 12.
>
> My initial idea was to model my variable using the dcat function, e.g.
> with
> for (j in 1:n ) {
> p[j] <- 1 / 12
> x[j] ~ dcat(p[j])
> },
> but this produces an error message of the form
> > error for node x[1] of type GraphCat.StdNode node invalid integer
> value given
> apparently because it is not possible to use dcat with missing data.
>
> The next idea was to use: for ( j in 1:n ) {
> x[j] <- round(x.cont[j])
> x.cont[j] ~ dunif(0.5, 12.5)
> }
> but when I compile this model it (rightly) produces an error message
> to say that x[1] has been defined more than once.
>
> Does anyone know if there is a way of doing this within BUGS...?
> Many thanks, Adam
>
--
Dr. Adam Butler
Postdoctoral Research Statistician
Biomathematics & Statistics Scotland
The King's Buildings, Edinburgh EH9 3JZ, UK
Tel: +44(0)131 650 4896
Fax: +44(0)131 650 4901
-------------------------------------------------------------------
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
|