I am a Master's student with the University of Michigan working on a GIS
habitat model for Black Bears. I am intending to use a bayesian model used
in a paper in the new Journal of Wildlife Management (A Bayesian Random
Effects Discrete-Choice Model for Resource Selection: Population-Level
Selection Inference). Unfortunately, I have almost no experience scripting
and am having difficulties understanding this model and the many error
messages I am receiving.
I have attached the model and a subset of my data for the data files below
this text. My
biggest question regards the '+lnavail[s]' part of the model. I thought it
was supposed to normalize the continuous covariates. But I get a message
when I compile the data that 'lnavail' has not been defined in the model or
the data. I tried using an earlier version of winbugs to see if that made a
difference but it didn't. If anyone could help me understand the purpose of
this function (as I can't find any reference to it in the literature).
The second question regards the 'tau2' of the model. when I compile the
model, I receive an error message that states the precision of abeta must be
positive. So when I replace the values 0.01 with 1, the model will
initialize but not with any other decimal place positive value. The model I
am using explicitly has these values as decimals. I don't understand why I
can't use these decimals. Any help would be appreciated.
#Discrete Choice random effects (one covariate)
model
{
# i is the index for animal, i = 1 , 2, ... , Na
# s is the index for the location cell, s = 1, 2, ... , Ns
# j is an index across all animal relocations, j = 1, 2, ... , N
# x is a matrix of all animal locations with column 1 = animal number,
column 2 = cell number
# z is a matrix of all cells
# with column 1 = cell number, remaining columns are covariate values for
each cell
# K is the number of covariates if only discrete resources, K = number of
resources (h-1 indicators + ln avail)
# Normalize continuous covariates (not ln avail in discrete resources)
# Likelihood specification
for(j in 1:N){
x[j,2]~dcat(p[x[j,1],1:Ns])
}
for(i in 1:Na){
for(s in 1:Ns){
eprod[i,s]<-exp(inprod(z[s,],abeta[i,])+lnavail[s])
p[i,s]<-eprod[i,s]/sumeprod[i]
}
sumeprod[i]<-sum(eprod[i,])
}
for(i in 1:Na){
for(k in 1:K){ abeta[i,k]~dnorm(beta[k],tau2[k]) }
}
for (k in 1:K){
beta[k]~dnorm(0.0, 0.01)
tau2[k] ~ dgamma(0.01, 0.01)
sig2[k] <- 1/tau2[k]
}
}
list(
N = 5, #number of animal relocations
Na = 3, #number of animals
Ns = 10, #number of grid cells
K = 10, #number of covariates
z=structure(.Data=c(
0.56742,0,1,0,0,0,0,0,0,0,
0.682,0,0,0,1,0,0,0,0,0,
0.12,0,0,0,1,0,0,0,0,0,
-2.3497,0,0,1,0,0,0,0,0,0,
-1.46396,0,1,0,0,0,0,0,0,0,
0.734,1,0,0,0,0,0,0,0,0,
-0.341,0,0,0,0,0,0,0,1,0,
-1.32,0,0,0,1,0,0,0,0,0,
1.65957,0,0,0,1,0,0,0,0,0,
0.514,0,0,0,0,0,1,0,0,0),
.Dim=c(10,10)).
x=structure(.Data=c(#animal number, grid cell location for all animal locations
1,2,
1,2,
2,3,
3,7,
3,8),
.Dim=c(5,2))
)
--Neil C
-------------------------------------------------------------------
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
|