Susanna - may I add a little to the detailed replies by both Kenneth and Emmanuel by also mentioning the very readable recent book by Marc Kery (Introduction to WinBUGS for ecologists) from Academic Press. Marc address this issue very early on and illustrates it extensively in both R (using model.matrix()) and BUGS to show the effect of using either approach. Having said this, I would agree with Emmanuel that Gelman & Hill is an exceptional book for learning how to develop regression and hierarchical regression models in R and WinBUGS.
regards,
Alan Kelly
Trinity College Dublin
On 13 Jan 2011, at 21:26, Emmanuel Charpentier wrote:
> Dear Susanna,
>
> I suppose that your BUGS model is something along the lines of
>
> model {
> for (i in 1:nobs) {
> Y[i]~dnorm(mu[i], tau)
> mu[i]<-SomeSpecifictionOfYourExpectedValueForY[i]
> }
> ## Priors here...
> }
>
> Your problem is an identifiability problem. You have indeed four degrees
> of freedom yo specify mu[i]. There is a lot of ways to use them :
>
> - One coefficient for each of your classes (the "general mean" being
> postulated null). In BUGS : mu<-beta[educ[i]]
>
> - One "overall mean", and three means for three of your four classes. I
> BUGS, mu[i]<-beta.0 + beta.educ[educ[i]], specifying a normal(0,1E-8) as
> a prior for beta.0 and beta.educ[1:3], beta.educ[4] being forced to 0.
>
> - One overall mean, one coeficient for each of your clsses, their mean
> (or their sum) being forced to 0. In BUGS : mu[i]<-beta.0+beta[educ[i]],
> but you have to add a small snippet along the lines of
>
> for (j in 1:4) {
> beta[i]<-beta.raw[i]-mean(beta.raw[])
> }
> and give priors to beta.O and beta.raw. Studying the traces will show
> you that the beta.raw arameters won't stabilize quickly, while the
> bet.educ will.
>
> This kind of unidentifiability might make convergence slower, but it can
> also seriously help convrgence by "unsticking" the sampler from a small
> region of the parameter space with unlikely values of parameters.
>
> It might also be interesting to give a prior to the *joint* distribution
> of beta.0 and beta, for example by giving them a multivariate normal
> distribution (inverse-Wishart model).
>
> I *highly* recommend reading Andrew Gelman and Jeniffer Hill's "Data
> analysis using regression and multilevel hierarchical models" (2007),
> which is, IMNSHO, the best modern textbook on regression. While bit
> short on formal derivation (almost none) and discussion of the
> "Frequentist-Bayesian schism" (not a bad thing, since this divide is at
> least in part an artefact of the past...), its presentation is quite
> enlightening on the fundamentals of regression, its uses and its limits.
> Furthermore, this book is relatively cheap (by todays crazy standards of
> book prices), and I hear that a PDF could be stolen on the 'Net (but by
> all means buy a physical copy anyway : you will return to it, annotate
> it, etc ...).
>
> The parts relevant to BUGS use in regression are in the all-but-last
> part of the book, and is centered on hierarchical models. But what is
> said here applies also to your simpler models.
>
> Please note that I said "BUGS use in regression", not "Bayesian
> regression". There is a lot more to be said about this (including
> epistemological and metaphysical issues), and I recommend to have a
> *serious* look at some "classic" textbooks such as Gelman & al.
> "Bayesian Data Analysis", Carlin & Louis "Bayesian Methods for Data
> Analysis", etc ... Don't miss Jim Albert's small an marvellous "Bayesian
> Computation with R", which says a *lot* more than its title announces
> (but won't touch BUGS) and Peter Congdon's textbooks (a bit more
> advanced than the previous ones).
>
> HTH,
>
> Emmanuel Charpentier
>
> Le jeudi 13 janvier 2011 à 14:36 +0530, Susanna Makela a écrit :
>> Hi all,
>>
>> What is the appropriate way to handle categorical covariates in WinBUGS? For
>> example, suppose I have a 4-category education covariate called "educ" with
>> levels none, primary, secondary, and tertiary. From what I've read, it seems
>> like I could include it in the model either by using dummies for each
>> category (minus the reference) - so beta1*educ1 + beta2*educ2 + beta3*educ3,
>> where educ1 is an indicator for primary education, etc - or as
>> beta[educ[i]]. I've tried it both ways and get similar - but not identical -
>> results. What is the difference between these two methods, and which is
>> correct?
>>
>> (Apologies if this seems like a basic question - I haven't been able to find
>> any clear answers in the manual, examples, or from googling, and it looks
>> like either there are no replies to similar questions on the list archive,
>> or they're just not posted.)
>>
>> Thanks!
>> Susanna
>>
>> -------------------------------------------------------------------
>> 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
>
> -------------------------------------------------------------------
> 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
>
-------------------------------------------------------------------
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
|