#################################################################################################### # Bayesian growth curve analysis (Modified from Eaton & Link 2011 and Connette et al. 2005) #################################################################################################### #### Data inputs ## NInd - number of individuals in dataset ## f - index of first capture ## l - index of last capture ## y - matrix of size data (mm) ## intervals - matrix of time interval data (days) model { # Prior Specification (Growth Model) # lambda ~ dunif(0.001,20) # loglambda ~ dunif(0.01,20) loglambda ~ dnorm(0.0,0.001) log(lambda) <- loglambda # a ~ dunif(25,35) loga ~ dnorm(0.0,0.001) log(a) <- loga tau.eps ~ dgamma(0.01,0.01) sd.eps <- 1/sqrt(tau.eps) logk ~ dnorm(0,1.0E-6) log(k) <- logk # Likelihood for (i in 1:NInd){ # Loop through individuals for (t in f[i]:f[i]){ # Survey of first capture y[i,t] ~ dnorm(H[i,t],tau.eps) # Measured size is the expected size +/- measurement error H[i,t] ~ dgamma(P[i,t],lambda) # True size at first capture is gamma distributed with shape=P[i,t], rate=lambda P[i,t] <- lambda*H.m[i,t] # Shape of gamma distribution is a product of lambda and the expected size at first capture H.m[i,t] ~ dunif(7,40) # Prior: Expected size at first capture } for (t in (f[i]+1):l[i]){ # Loop through surveys (from subsequent captures) y[i,t] ~ dnorm(H[i,t],tau.eps) H[i,t] <- H[i,t-1]+increment[i,t] # True size = previous size plus a random gamma increment increment[i,t] ~ dgamma(P[i,t],lambda) P[i,t] <- lambda*abs(H.m[i,t]-H.m[i,t-1]) H.m[i,t] <- H.m[i,t-1]+(a-H.m[i,t-1])*(1-exp(-k*intervals[i,t]/1000)) # Expected size at time t } #t } #i } #model