I'm new to Python and am having trouble translating a model I wrote in R into Python language. If anyone has any suggestions on resources or code examples that might help I would greatly appreciate it. I've seen some snippets of code and text in help files, etc. but none are quite annotated or specific enough for a newbie to Python. The following model is an N-mixture abundance model modeled after Royle (2004):N-mixture models for estimating population size from spatially replicated counts. Basically it describes a Poisson/Binomial mixture model where-in the Where Z_i is wetland-level abundance and is treated as a random variable with a Poisson distribution. The observed abundance of broods (yij) on site i and during visit j then follows a binomial distribution with index parameter Z_i and success parameter p_ij. Abundance 〖(λ〗_i) is modeled through a log link as a function of a covariates and detection probabilities are modeled through a logit link as a function of b covariates.
model {
## Priors
a0 ~ dunif(-5, 5)
a1~ dunif(-5, 5)
a2 ~ dunif(-5, 5)
a3~ dunif(-5, 5)
b0 ~ dunif(-5, 5)
b1~ dunif(-5, 5)
b2~ dunif(-5, 5)
## Model
# State process
for(i in 1:5175) {
logit(psi[i]) <- min(max(a0 + a1*wetarea[i] +
a2*percentcover[i] +
a3*(year[i]), -99), 99)
Z[i] ~ dbern(psi[i])
# Detection process
for(j in 1:3) {
logit(p[i, j]) <- b0 + b1*emergentcover[i, j] +
b2*time[i]
y[i, j] ~ dbin(p[i, j], Z[i])
}
}
## Derived parameters
Zsum <- sum(Z[]) # Number of sites occupied
PAO <- Zsum / 100 # Proportion of sites occupied (aka PAO)
}
Thanks in advance for any help/suggestions
There are several examples on the PyMC wiki, including occupancy and mixture models. I would look at those; your model looks pretty straightforward.