I find it hard to offer good advice without seeing the entire model. However, I have a few thoughts which might be helpful.
1) When I do things like this, I find it easier to organize my data in 'long form.' For example, I would create a table with one row for each measurement, and one column for each covariate. Thus, you would have columns for (at least) transect, year, observer, snow depth, and temperature. If you have multiple measurements from year t, then all rows with measurements from year t will have the same value in the 'snow' column, because snow was the same on all transects in year t. Similarly, all rows with measurements from year t will also have the same value in the 'temperature' column, because temperature was the same on all transects in year t. If you put your data in long form, it will simplify your model. Note that your suggestion has three loops: one for k, one for year, and one for transect. If you put your data in long form, then you only need to have one loop, a loop through each row in your data set.
For the next two thoughts, I'll assume the data are in long form, and the rows are indexed by k.
2) You can assume a form for the effect of both snow and temperature. The simplest assumption is that they have a monotonic/linear effect on log(lambda[k]), and that this effect is the same across all transects. In this case, you would add slope terms for each of these effects into the overall model.
Uninformative priors for the two new beta terms:
beta.s~dnorm(0, .01)
beta.t~dnorm(0, .01)
and the overall model would become:
for(k in 1:number_of_data_points)
{
log(lambda[k]) <- {stuff in original model} +
beta.s*snow_depth[k] +
beta.t*temperature[k]
}
3) It may be that this assumption about the form of the snow and temperature effects is too simplistic. You noted that you thought the slopes (betas) might be different on different transects. In this case, you could create a set of betas as:
for(o in 1:ntransects)
{
beta.s[o]~dnorm(0, .01)
beta.t[o]~dnorm(0, .01)
}
and the overall model would become
for(k in 1:number_of_data_points)
{
log(lambda[k]) <- {stuff in original model} +
beta.s[transect[k]]*snow_depth[k] +
beta.t[transect[k]]*temperature[k]
}
Hopefully that helps,
Tim Handley
Research Assistant
Channel Islands National Park
(Will be working from both CHIS and SAMO)
CHIS Phone: 805-658-5759 (Mon, Tue, Wed)
SAMO Phone: 805-370-2300 x2412(Thu, Fri)
-------------Original Message Below---------------------------
Hi,
I am running a log-linear model in winbugs :
log(lambda[k]) <- theta[transect[k]] + beta*(year[k] - fixedyear) + alpha[observer[k]] + gamma[year[k]]+ epsilon[k],
where theta is the transect effect, beta is the slope, alpha is the observer effect, gamma the overall year effect and epsilon the error term.
Now I want to add the two environmental variables temperature and snow depth (beta.t and beta.s). Since I suspect these variables to have different effects on different transects, I'm a little confused as to how to add them to the equation.
The values I have for the two variables are one value per year - so basically the same value over all the transects per year.
Since their effect would vary with both year and transect, should I add them as
for (t in 1:nyears){
for(o in 1:ntransects){
mu.beta.t[t,o] <- mu.snow[t,o]*snow[t]
beta.t [t,o]~dnorm(mu.beta.t[t,o], tau.beta
}
}
tau.beta ~dgamma(1,0.1)
and then just add "+beta.t[year[k],transect[k]] "to the overall model?
Thanks,
Lene
______________________________
Lene Jung Kjaer, PhD
NSERC Visiting Fellow
Parks Canada
Western and Northern Service Centre
145 McDermot Avenue
Winnipeg, MB, R3B 0R9, Canada
office: 204-984-5821
Mobile: 204-951-1290
fax: 204-983-0031
email work: [log in to unmask]
email home: [log in to unmask]
-------------------------------------------------------------------
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
|