WinBUGS users wanting to analyze unbalanced hierarchical data:
Use "nested indexing". Structure your data so that each case is an
observation at the lowest level (in Gerdien's problem, each observation is
a farm). Include identifiers for the higher-level classifications, e.g.,
farm[] country[] region[] ncows[]
1 1 1
2 1 1
.
.
91
98 1 2
99 1 2
.
.
188 1 2
189 1 3, etc.
(you don't actually need a variable indexing farms, this is just for
illustration).
Then instead of three nested loops, your specification of the likelihood
has only one loop:
for( i in 1 : NFARMS) {
AP[country[region[i]]] ~ dbin(probpos[country[region[i]]],
ncows[country[region[i]]])
Where NFARMS is the *total* number of farms in the dataset. You'll need
separate loops over the indices for the higher levels to assign priors at
each stage. The indices should increment continually (e.g., the first
region in country 2 should have region=5)
Good Luck -- Jeff
At 01:53 PM 8/24/01 -0500, you wrote:
>At 10:58 AM 4/20/00 -0300, Teresa Cristina Martins Dias wrote:
>Dear users
>
> I have the same request. Could I receive the answer too?
>Thanks
>
> >Dea Winbugs users,
> >
> >I would like to receive the answer the question: Unbalanced data in a
> >hierarchical model ( Gerdien Van Schaik ).
> >
> >Teresa Cristina
> >-----Mensagem original-----
> >De: Gerdien Van Schaik <[log in to unmask]>
> >Para: [log in to unmask] <[log in to unmask]>
> >Data: Thursday, August 23, 2001 4:39 PM
> >Assunto: Unbalanced data in a hierarchical model
> >
> >
> >>Dear Winbugs users,
> >>
> >>I am running a hierarchical model in Winbugs of testdata of farms within
> >>region within country. I have unbalanced data because I have a different
> >>number of farms per region and per country. Country 1 has 4 regions and 91,
> >>97, 93, and 97 farms per region. Country 2 has 3 regions with 30 farms in
> >>each region. I am interested in the region and country effect and therefore
> >>combined the two datasets.
> >>My datastructure is a rectangular array and looks as follows:
> >>
> >>ncows[,1,1] probpos[,1,1] ncows[,2,1] probpos[,2,1] ncows[,3,1]
> >> probpos[,3,1] ncows[,4,1] probpos[,4,1] ncows[,1,2]
> >>probpos[,1,2] ncows[,2,2] probpos[,2,2] ncows[,3,2]
> >>probpos[,3,2] ncows[,4,2] probpos[,4,2]
> >>
> >>with the data underneath the headings in columns.
> >>
> >>In my model the hierarchy is modeled with the arrays i (=farm), j
> >>(=region), and k (=country). See a sample of the model below.
> >>
> >>model;
> >>{
> >>for( i in 1 : 97 ) {
> >>for( j in 1 : 4 ) {
> >>for( k in 1 : 2 ) {
> >>
> >> AP[i , j , k] ~ dbin(probpos[i, j, k], ncows[i , j , k])
> >>
> >> }
> >> }
> >> }
> >>}
> >>
> >>However, to be able to run this model I had to make the data balanced by
> >>artificially creating 4 regions in every country and 97 farms in every
> >>region. I would rather not have to create extra data because I may
> >>introduce errors by doing so.
> >>Can anybody help me with an array or data-structure that would solve my
> >>problem with different numbers of regions per country and different number
> >>of farms per region? I would be very obliged.
> >>
> >>Gerdien van Schaik
> >>
> >>***************************************************************************
> >********
> >>Ms. Gerdien van Schaik, PhD
> >>Cornell University,
> >>College of Veterinary Medicine
> >>Department of Population Medicine and Diagnostic Sciences (box 26),
> >>Ithaca, NY, 14853,
> >>USA.
> >>ph. 607 253-4329
> >>fax 607 253-3083
> >>***************************************************************************
> >********
> >>
> >>-------------------------------------------------------------------
> >>To mail the BUGS list, mail to [log in to unmask]
> >>You can search old messages at www.jiscmail.ac.uk/lists/bugs.html
> >>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
> >>
> >>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]
> >You can search old messages at www.jiscmail.ac.uk/lists/bugs.html
> >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
> >
> >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]
>
>Asimina L. Mila
>Graduate Student - Research Assistant
>Plant Pathology Dept.
>351 Bessey Hall
>Iowa State University
>Ames, IA 50011
>515-294-3660
>[log in to unmask]
>
>-------------------------------------------------------------------
>To mail the BUGS list, mail to [log in to unmask]
>You can search old messages at www.jiscmail.ac.uk/lists/bugs.html
>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
>
>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]
****************************
Jeffrey A. Welge, Ph.D.
Assistant Professor
Department of Psychiatry &
Center for Biostatistical Services
University of Cincinnati Medical Center
Tel:(513) 558-0856
E-mail: [log in to unmask]
-------------------------------------------------------------------
To mail the BUGS list, mail to [log in to unmask]
You can search old messages at www.jiscmail.ac.uk/lists/bugs.html
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
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]
|