Hello BUGS usres!
I am modelling multinomial data and one needs such data in contingency
table "format". Since I am building model step by step i.e. adding each
variable at the time, there is quita a lot of coding and care needed
on data preparation. Is is possible to list data in BUGS in expanded
format and then create a contingency table from it in BUGS?
My code and data are bellow signature.
Thanks for hints.
Lep pozdrav / With regards,
Gregor Gorjanc
----------------------------------------------------------------------
University of Ljubljana
Biotechnical Faculty URI: http://www.bfro.uni-lj.si/MR/ggorjan
Zootechnical Department mail: gregor.gorjanc <at> bfro.uni-lj.si
Groblje 3 tel: +386 (0)1 72 17 861
SI-1230 Domzale fax: +386 (0)1 72 17 888
Slovenia, Europe
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
you have no certainty until you try." Sophocles ~ 450 B.C.
----------------------------------------------------------------------
# BUGS model code
model
{
## Likelihood
## Multinomial response
y[1:colourN] ~ dmulti(p[1:colourN], N)
for (i in 1:colourN) { # loop around choices
p[i] <- phi[i] / sum(phi[])
log(phi[i]) <- alpha[i]
}
## Priors
alpha[1] <- 0 # zero contrast for baseline choice
for (i in 2:colourN) { # vague prior
alpha[i] ~ dnorm(0, 0.00001)
}
}
# Data
list(N=1.50000E+03, colourN=4.00000E+00,
y=c(3.21000E+02, 2.98000E+02, 5.81000E+02, 3.00000E+02))
# Inits
list(alpha=c(NA, 5.00000E-01, 1.00000E-01, 2.00000E-01))
-------------------------------------------------------------------
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
|