Hello.
I have been struggling with a how to code a particular model in WinBUGS and I could use some advice. I am hoping to propagate error across both gamma and normal distributions.
My model consists of two parts. For the first, I have data with which I want to estimate shape and rate parameters of a gamma distribution. I then want to turn the shape into a mean value. The twist is that I want to do this for multiple study sites where each study site has a different specification.
For example:
#Site 1
for(i in 1:n.species.1){
for(j in 1:n.species.2){
for(k in 1:n.species.3){
species.1[i] ~ dgamma(shape.1, rate.1)
species.2[j] ~ dgamma(shape.2, rate.2)
species.3[k] ~ dgamma(shape.3, rate.3)
shape.1<-pow(mean.species.1/sd.species.1, 2)
shape.2<-pow(mean.species.2/sd.species.2, 2)
shape.3<-pow(mean.species.3/sd.species.3, 2)
total[1]<-5*mean.species.1 + 3*mean.species.2 + 10*mean.species.3
}
}
}
#Site 2
for(i in 1:n.species.1){
for(j in 1:n.species.2){
for(k in 1:n.species.3){
species.1[i] ~ dgamma(shape.1, rate.1)
species.2[j] ~ dgamma(shape.2, rate.2)
species.3[k] ~ dgamma(shape.3, rate.3)
shape.1<-pow(mean.species.1/sd.species.1, 2)
shape.2<-pow(mean.species.2/sd.species.2, 2)
shape.3<-pow(mean.species.3/sd.species.3, 2)
total[2]<-3*mean.species.1 + 8*mean.species.2 + 0*mean.species.3
}
}
}
My next step is to then use my total values from each site in a normal linear regression:
for(i in 1:n.total){
mu<-alpha + beta.1*variable.1[i] + beta.2*variable.2[i]
total[i] ~ dnorm(mu, tau)
}
Outside of WinBUGS, I would use my species data to estimate the shape and rate of a gamma distribution. For each study site, I would draw the appropriate number of samples from these gamma distributions and sum them, yielding a
total for each study site. However doing so does not take into account the error in estimating the shape and then summing across species to yield a site total. I have tried specifying the model several ways but each time I am told the shape parameters are multiple nodes. If anyone knows whether it's possible to code such a model, I'd love to hear it. Thank you very much!!
Dr. Richard Feldman
Dept. of Biology
Trent University
Peterborough, ON Canada
-------------------------------------------------------------------
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
|