Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we get the residuals from JAGS output?

Say we fit a Bayesian linear mixed model using JAGS (or WinBUGS), does the output object include the model residuals? How can we find the residuals?

Thanks!

like image 447
askming Avatar asked Dec 11 '25 06:12

askming


1 Answers

A JAGS (BUGS) model simply outputs the values of the nodes in the model you have told it to monitor. To get residuals you need to define those in the model and then monitor them. For example

model {
 bResponse ~ dnorm(0, 5^-2)
 sResponse ~ dunif(0, 5)
 for (i in 1:length(Response)) {
   eResponse[i] <- bResponse
   Response[i] ~ dlnorm(eResponse[i], sResponse^-2)
   Residual[i] <- (log(Response[i]) - log(eResponse[i])) / sResponse
 }
} 

were Residual[i] defines a residual for each of the i values of the Response. Note the above example does not deal with specifying which values to monitor.

like image 100
joethorley Avatar answered Dec 14 '25 17:12

joethorley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!