Hello All,
sorry for the simple question. I've searched through prior conversations on the subject of truncation and couldn't find anything to solve my problem.
I am working on a model with truncation throughout, with all upper and lower bounds of truncation defined. When I try to define the model using nimbleModel() or run the code with nimbleMCMC straight from the model code I get the following error.
Defining model
[Note] Using 'ccr,csd,ndat' (given within 'constants') as data.
Error in getSymbolicParentNodesRecurse(code, constNames, indexNames, nimbleFunctionNames, :
R function 'T' has arguments that cannot be evaluated; either the function must be a nimbleFunction or values for the following inputs must be specified as constants in the model: character(0).
Thanks in advance for the help
### code below here #######
ipm_epsi_mod <- nimbleCode( {
# This is a demographic IPM
# the model estimates population size, reproduction, and
# survival for female caribou in
# three age classes (calves, subadults, adults)
# Priors
## Reproduction
repr_mu ~ T(dnorm(log(ccr1/(1 - ccr1)), 10),-10,10)
## Survival
sJuv_mu ~ T(dnorm(log(sC.mu/(1-sC.mu)), 10),-10,10)
sAF_mu ~ T(dnorm(log(sF.mu/(1-sF.mu)), 10),-10,10)
# Hyper-Priors and Linear Predictors
## Standard deviations for random effects
R_tau <- pow(repr_sig, -2)
repr_sig ~ dunif(0, 50)
sA_tau <- pow(sA_sig, -2)
sA_sig ~ dunif(0, 50)
sJ_tau <- pow(sJ_sig, -2)
sJ_sig ~ dunif(0, 50)
## Linear Predictors
for(yr in 1:nYear){
# Reproduction: Probability an Adult Cow Reproduces in each year
repr_yr[yr] ~ T(dnorm(0, R_tau),-10,10)
logit(Repr[yr]) <- repr_mu + repr_yr[yr]
# Survival[year, age, sex]
## Calf Survival (constant over time)
sJuv_yr[yr] ~ T(dnorm(0, sJ_tau),-10,10)
logit(sJuv[yr]) <- sJuv_mu + sJuv_yr[yr]
## Adult and Sub-adult Survival Probability in each year
## Both males and females vary at the same annual rate (sA_yr)
sA_yr[yr] ~ T(dnorm(0, sA_tau),-10,10)
logit(sAf[yr]) <- sAM_mu + sA_yr[yr]
}
# Initial starting Population [year, age, sex]
## Calf and sub-adult starting pop at 0
nReps[1] <- nJf[1]
nJf[1] <- T(dnorm((nC1*ccr1), 0.0001),0,550000)
nYf[1] <- 0
## Adult starting population
nAf[1] ~ T(dnorm(nC1, 0.0001),0,550000)
totC[1] <- nJf[1]
totF[1] <- nJf[1] + nYf[1] + nAf[1]
totN[1] <- totF[1] + (totF[1]*bcr1)
# Process Model for Three Age-Classes and Two sexes
###################################################
for(yr in 2:nYear){
# Calves (reproduction)
c.Mu[yr] <- nAf[yr]*Repr[yr]
nYoung[yr] ~ dnorm(c.Mu[yr], 1/abs(c.Mu[yr]))
nJf[yr] <- nYoung[yr]*0.5
# Sub-adults (1-2yrs)
nYf[yr] ~ dbin(sJuv[yr-1], nJf[yr-1])
# Adults (≥2yrs)
nAf[yr] ~ dbin(sAf[yr-1], (nYf[yr-1] + nAf[yr-1]))
# Calculate totals in each year
totC[yr] <- nJf[yr]
totF[yr] <- nJf[yr] + nYf[yr] + nAf[yr]
totN[yr] <- totF[yr] + (totF[yr]*bcr1)
}
# Observation Models for Data Objects
######################################
# Breeding Cow Abundance (Aerial Surveys)
for(i in 1:nndat){
ndat[i,2] ~ T(dnorm(nAf[ndat[i,1]], ndat[i,4]),0,550000)
}
# Spring Calf:Cow Ratio (Aerial and Ground Surveys)
for(i in 1:nccr){
ccr[i,2] ~ T(dnorm(ccRat[ccr[i,1]], ccr[i,4]),0,1)
}
# Cow Survival (Telemetry)
for(i in 1:ncsd){
csd[i,2] ~ T(dnorm(sAf[csd[i,1]], csd[i,4]),0,1)
}
# Derive calf:cow and bull:cow ratios from abundance parameter estimates
# Age ratio (ccRat), total young/females 1.5 and older
for(yr in 1:nYear){
ccRat[yr] <- (nJf[yr])/(nYf[yr] + nAf[yr] + 1)
}
# Derive Population Growth Rate (lambda)
# arbitrary value of 1 is given to the first year
lambdaF[1] <- 1
for(yr in 2:nYear){
lambdaF[yr] <- (totF[yr] + 1)/(totF[yr-1] + 1)
}
lambda[1] <- 1
for(yr in 2:nYear){
lambda[yr] <- (totN[yr] + 1)/(totN[yr-1] + 1)
}
})