I'm interested in fitting linear splines within a JAGS model, but would like to estimate the number and placement of knots. Is there any way to trick JAGS so that I can place a prior distribution on the upper index of a for loop?

For example:

for(i in 1:nk){

knot[i] ~ dunif(x_min,x_max)

}

knots <- sort(knot[])

nk ~ dpois(15)

x_min and x_max are the range of the dependent variable x. This throws an error in JAGS.