想象一个简单的增长模型。 我如何才能提前一步预测?
# Priors and constraints
N.est[1] ~ dunif(0, 10) # Prior for initial population size
mean.lambda ~ dunif(0, 10) #
mean.psi ~ dunif(0, 10) #
sigma.proc ~ dunif(0, 10)# Prior for sd of state process
sigma2.proc <- pow(sigma.proc, 2)
tau.proc <- pow(sigma.proc, -2)
sigma.obs ~ dunif(0, 10) # Prior for sd of observation process
sigma2.obs <- pow(sigma.obs, 2)
tau.obs <- pow(sigma.obs, -2)
sigma.psi ~ dunif(0, 10) # Prior for sd of observation process
psi2.psi <- pow(sigma.psi, 2)
tau.psi <- pow(sigma.psi, -2)
# Likelihood
# State process
for (t in 1:(T-1)){
lambda[t] ~ dnorm(mean.lambda, tau.proc)
psi[t] ~ dnorm(mean.psi, tau.psi)
N.est[t+1] <- 10/ ( 1+ exp(- psi[t] *(N.est[t] * lambda[t]) ) ) #N.est[t] * lambda[t] + psi[t]
}
# Observation process
for (t in 1:T) {
y[t] ~ dnorm(N.est[t], tau.obs)
}
&#13;
答案 0 :(得分:1)
您要做的只是在响应向量y
中将要预测的单位设置为NA
,然后生成y
的复制样本;
y.pred[t] ~ dnorm(N.est[t], tau.obs)
检查y
和y.pred
res <- y - y.pred