The problem is here:
N[i,t+1] ~ dpois(N[i,t] * r[i,t])
Distributions take variables as arguments, not expressions. So, at the
very least, you should write this as
mu[i,t+1] <- N[i,t] * r[i,t])
N[i,t+1] ~ dpois(mu[i,t+1])
But this is probably better:
log(mu[i,t+1]) <- log(N[i,t]) + logr[i,t]
N[i,t+1] ~ dpois(mu[i,t+1])
because it uses a log-link function, which will make BUGS happier. It
also means you can easily extend the model, e.g. if you want to make hte
man logr population specific:
log(mu[i,t+1]) <- log(N[i,t]) + logr[i] + epsR[i,t]
And some practical advice (from lots of experience!): you can use what
seem to be tight priors on logr (because the range of reasonable values
is usually quite tight), and you'll also need to set good initial
values, otherwise the model won't start. Of course they're easy to find:
start by regressing log(N) against t and using the slope as an init.
HTH
Bob
On 30/07/18 19:47, IndyJones wrote:
> Greetings,
>
> I want to explain variation in population growth rate r of some species. I'd like to treat r as a random variable (give it a distribution), and then model the mean of that distribution in a linear model. I tried to define r to be the ratio of population size at time t+1 and t, and then model the log-transformed r with a linear model. But my model specification seems to have a bug in it because WinBUGS gives me an error "expected right parenthesis". I would welcome any advice. Thank you! (Code provided below.)
>
> Indy
>
> model {
> # Specify the priors for all parameters in the model
> # Priors on intercepts
> a0 ~ dnorm(0,0.01)
> b0 ~ dnorm(0,0.01)
>
> #priors on slopes
> a1 ~ dnorm(0,0.01)
>
> taulr ~ dgamma(10,1)
>
> # First year
> for(i in 1:nsite){
> N[i,1] ~ dpois(lambda[i])
> log(lambda[i]) <- a0 + a1*elev[i]
> }
>
> # Later years
> for(i in 1:nsite){
> for(t in 1:(nyear-1)){
> N[i,t+1] ~ dpois(N[i,t] * r[i,t]) # Express N[i,t+1] in an autoregressive manner
> log(r[i,t]) <- logr[i,t]
> logr[i,t] ~ dnorm(mulr[i,t], taulr) # model log(r) as a normal random variable with mean modelled by covariates
> mulr[i,t] <- b0
> }
> }
>
> # End model specification
> }
>
> -------------------------------------------------------------------
> This list is for BUGS users to support each other, ask questions or share ideas.
> 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
>
--
Bob O'Hara
Institutt for matematiske fag
NTNU
7491 Trondheim
Norway
Mobile: +49 1515 888 5440
Homepage: http://www.ntnu.edu/employees/bob.ohara
Journal of Negative Results - EEB: www.jnr-eeb.org
-------------------------------------------------------------------
This list is for BUGS users to support each other, ask questions or share ideas.
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
|