pinkisntwell
2011-06-30
Is there a way to redefine variables in jags? It seems like there's not, so if
this is indeed the case, will it be possible in the future?
Martyn Plummer
2011-06-30
I don't know what you mean. Can you give an example of what you want to do,
say what you expect to happen and what does happen?
pinkisntwell
2011-07-01
For example, it would be useful to be able to do something like this:
var <- 0
for (i in 1:FOO) {
var <- function(data_)
}
If I try to do this in Jags now I get an error: "Attempt to redefine variable
var"._
Martyn Plummer
2011-07-01
See the user manual, under "Data transformations"
pinkisntwell
2011-07-01
As far as I can see "Data transformations" is about assigning values twice,
once as data and once during sampling. Is this your suggestion? If so, I want
something different, I want to redefine a variable during sampling. This is
useful in dynamic bayesian networks, where a value at one time point depends
on the value of the previous time point, so it's useful to have a 'previous
value' variable which can be reassigned.
Martyn Plummer
2011-07-01
Ah I see. BUGS is not a procedural language. It is a declarative language that
describes the static relationships between variables in a model, so you cannot
redefine a variable. For a dynamic Bayesian model you need to add an explicit
time dimension to your variables, e.g
for (j in 1:N) { x[j, 1] <- 0 for (t in 2:T) { x[j,t] <- somefunction(x[j,t-1], otherdata) } }
This can make models quite large but JAGS has a number of ways of keeping the
calculations relatively efficient.
pinkisntwell
2011-07-01
What you point out is the straightforward way, but I am certain that it will
render my model unmanageable. It's already too large at about 8M nodes.