I've compiled answers to several questions I've posted recently, by way of elucidating simple problems for others. Thank you all for your help when I've needed it!


Question: Meaning of error message “Sorry, something went wrong in procedure Stack.Value in module GraphStack”, using following code:

{

#Apply Richard's after and Linear before the change in growth rate (cgr)

lag ~ dnorm(joinpoint, tau.lag)

joinpoint <- (step(yr - cgr) * (k / pow(1 + r.max * exp(r.rate * (yr - tmg)), (1 / r.max)))) + 

((1 - step(yr - cgr)) * (lo.CaliforniaQuail[1] * pow(l.mu, yr)))

yr ~ dunif(5, 51)

cgr ~ dnorm(break, tau.cgr)

 

#Determine linear population growth rate

for (i in 1:N) {

mu.linear[i] ~ dnorm(lambda[i], tau.linear)

lambda[i] <- ((lo.CaliforniaQuail[i + 1]) / (lo.CaliforniaQuail[i]))

}

#Species level parameters

k ~ dunif(0, popsize)

r.max ~ dunif(0, popsize)

r.rate ~ dunif(0, 10)

tmg ~ dnorm(popsizetime, tau.tmg)

l.mu <- mean(mu.linear[])

 

tau.lag ~ dunif(0,1)

sd.lag <- 1/(tau.lag * tau.lag)

tau.cgr ~dunif(0,1)

sd.cgr <- 1/(tau.cgr * tau.cgr) 

tau.linear ~ dunif(0, 1)

sd.linear <- 1/(tau.linear * tau.linear)

tau.tmg ~ dunif(0,100)

sd.tmg <- 1/(tau.tmg * tau.tmg)

}

 

Answer: “This is the equivalent of the Trap window in WinBUGS - it's a crash that the developers haven't got around to handling with a proper error message.   If you rename Bugs/Code/Traphandler.ocf in the OpenBUGS installation, or move this file somewhere else, you can get a trap window, which is mildly more informative, though still aimed at programmers rather than users.   

In your case, that tells me the error happens when trying to calculate the node "joinpoint", in terms of the variable "
l.mu".    It appears that one of the elements of mu.linear[] is infinite (Info -> Node info... -> values) after the initial values are generated, which causes the crash when calculating "joinpoint".  Looks like this is because several of the lambda[]  are defined by a division by zero.”

 

Question: The following model works:

for( i in 1 : N ) {

v[i] ~ dnorm(mu[i],tau)

mu[i] <- b0[sp[i]] + b1[sp[i]] * d2h[i]

numerator[i] <- (mu[i] - vbar)*(mu[i] - vbar)

denominator[i] <- (v[i] - vbar)*(v[i] - vbar)

}

r2 <- sum( numerator[] ) / sum( denominator[] )

 

In a separate model I have a bit of code that looks functionally identical to me, but it provides the error message "invalid use of range construct in when":

 

for (i in 1:Y) {

yr[i] <- year[i] - cgr

cgr ~ dnorm(break, tau.cgr)

}

lag ~ dnorm(joinpoint, tau.lag)

joinpoint <- (step(yr[])*mu.richards) + ((1 - step(yr[])) * mu.linear)

 

I've italicized the portions I'm confused about. In the first model, I define variables "numerator" and "denominator" within a for-loop, indexed by 'i', and then call them with without 'i', just [], outside the for-loop. In the second model I do the same thing with yr[], but it won't compile. 

 

Any advice as to what this error message is telling me I'm doing wrong?

 

Answer: “step() takes a single value as its argument not a vector, whereas sum() expects a vector.”

 

Question: Meaning of error message “Sorry, something went wrong with procedure Power in module MathFunc”

 

Answer: “The error message means that at some point in your code a value was raised to the power of x, but that it was done incorrectly. This could mean that you entered the inputs into the function wrong, that one or both of the inputs is not a number or is related to infinity, or that the output of the function is not a number/infinity.”


Kevin Aagaard

PhD Candidate

Rutgers University

------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list