Jags / Bugs提前一步预测

时间:2015-03-17 12:38:50

标签: mcmc winbugs jags

想象一个简单的增长模型。 我如何才能提前一步预测?



 # 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;
&#13;
&#13; 这是一本书,这个例子。如何获得一步预测,因为我对平滑输出不感兴趣。

1 个答案:

答案 0 :(得分:1)

您要做的只是在响应向量y中将要预测的单位设置为NA,然后生成y的复制样本;

y.pred[t] ~ dnorm(N.est[t], tau.obs)

检查yy.pred

之间的残差

res <- y - y.pred

Using JAGS in R with the rjags package