如题,程序如下,但load data 后报错:value of uniform lambda[2,1] must be greater than lower bound,其实就只是限制了lambda[1, j] 小于lambda[2, j] ,为什么出错了呢?
model {
####################################
#Modelling for the previous seasons#
####################################
#Modelling for the first week of every season
for (j in 1:nyears) {
dif.rates[1, j] ~ dnorm(0,tau[1, j])
tau[1, j] <- pow(lambda[comp[1, j], j],-2)
}
#Modelling for the later weeks of every season
for (j in 1:nyears) {
for (i in 2:nweeks) {
dif.rates[i, j] ~ dnorm(mu[i, j],tau[i, j])
tau[i, j] <- pow(lambda[comp[i, j], j],-2)
mu[i, j] <- ro*dif.rates[i-1, j]*equals(comp[i, j],2)
}
}
#Temporal dependence parameter
ro ~ dunif(-1,1)
#Prior distributions for standard deviations in every season
for (j in 1:nyears) {
lambda[1, j] ~ dunif(linf,lmed1)
lambda[2, j] ~ dunif(lmed2,lsup)
}
#Prior distributions for the hyperparameters of the standard deviations
linf ~ dunif(a,b)
lmed1 ~ dunif(linf,b)
lmed2 ~ dunif(lmed1,b)
lsup ~ dunif(lmed2,b)
#Hidden Markov layer definition
for (j in 1:nyears) {
comp[1, j] ~ dcat(P0[])
for (i in 2:nweeks) {
comp[i, j] ~ dcat(P.mat[comp[i-1, j], ])
}
}
#Hyperparameters of the hidden layer
P0[1]~dbeta(0.5,0.5)
P0[2]<-1-P0[1]
P.mat[1,2]<- 1-P.mat[1,1]
P.mat[2,1]<- 1-P.mat[2,2]
P.mat[1,1] ~ dbeta(0.5,0.5)
P.mat[2,2] ~ dbeta(0.5,0.5)
}