そのため、母集団のハザード モデルを実行している間、このコードに取り組んできましたが、最初のパラメーターの 1 つで、修正方法がわかりません。これは、問題を引き起こしているコードの領域です。私は Notebook++ でコーディングし、R で実行しています。WinBUGS で開いて実行します。Hz.Scale は、私が苦労しているパラメーターであり、エラーが発生します。
# Define model - Model 02 = hazard
if(detect.fun=="hazard"){
sink(paste(top.dir,model.name,sep="/"))
cat("
model{
# Priors
psi ~ dunif(0,1) # Data augmentation parameter
#hz.scale ~ dgamma(0.1,0.1) # Scale parameter for hazard distribution (sigma) #ORIGINAL CODE
hz.scale ~ dgamma(0,10) # Scale parameter for hazard distribution (sigma) #change the parameters to test if it really runs
hz.shape ~ dunif(0.001,1000) # Shape parameter for hazard distribution (b in green & yellow book)
lambda ~ dunif(0,20) # Expectation for cluster size
# Likelihood
## Construct conditional detection probability (log(p[g])) and Pr(x) (pi[g]) for each bin (g)
for(g in 1:nD){
# Hazard model:
cloglog(p[g]) <- hz.scale*log(hz.shape) - hz.scale*log(midpt[g]) # Kery and Royle 2016 page 507
# Probability of x in each interval
pi[g] <- delta[g]/B
}#g
for(i in 1:(nclus+nz)){
z[i] ~ dbern(psi) # Real observation or augmented?
dclass[i] ~ dcat(pi[]) # population distribution of distance class
mu[i] <- z[i] * p[dclass[i]] # p depends on distance class
y[i] ~ dbern(mu[i]) # Observed or not?
clsz[i] ~ dpois(lambda) # Poisson process for cluster size
}#i
# Derived quantities
num.clusters <- sum(z[]) # Number of clusters
back.lambda <- lambda+1 # Back-transformed lambda (minimum is 1)
total.pop <- num.clusters*back.lambda
}#model
",fill=TRUE)#cat
sink()
# Inits function and parameters to save
inits <- function(){list(psi=runif(1),z=y,hz.shape=runif(1,40,200),hz.scale=rgamma(1,0.1,0.1),lambda=runif(1,0,10))}
params <- c("hz.scale","hz.shape","num.clusters","back.lambda","total.pop")
}# hazard
# hazard