Print

Print


Dear List,

I am an occasional winBUGS user, and I do not know the syntax well. I hope
the following question is not too silly. I am working on a convolution
problem, and need to evaluate expressions of the form:

for(index in 1:NROWS)
{
ysum=0.0
for(shift in 1:index)
{
coef = (index-shift) * x1
ysum = ysum + yin[shift] * exp(-coef)
}
yout[index]=ysum*x2
}

But a direct translation of this generic code into BUGS results in multiple
definition errors for coef and ysum. The following code compiles without
error.

for(index in 1:NROWS)
{
for(shift in 1:index)
{
coef[index, shift] <- (index-shift) * x1[jsubj[index]]
ytemp[index, shift] <- ymca[index] * exp(-coef[index, shift])
}
yconv[index] <sum(ytemp[index,1:index]) *x2[jsubj[index]]
}

Congdon (2001, Bayesian Statistical Modelling) uses similar syntax in a
program for regression with autocorrelated errors (Prog. 7.10). But given a
large problem, this would appear to make extravagant use of memory. (Also
takes ages to compile.) Presumably, the extra indexing operations must
result in substantial run-time cpu demands. I can see the reason for
getting the compiler to flag overwrites as an error. Nevertheless, is there
a way of 'overwriting' temporary results, thus replacing the unwanted
matrix/vector ops with scalar ops, and avoiding the resulting overheads?

Many thanks,

Martin
*****************

Martin King
Biophysics, Radiology & Physics Unit
Institute of Child Health/Gt Ormond Street Hospital for Children
30 Guilford Street
London WC1N 1EH, UK
tel: + 44 (0)20 7905 2273
fax: + 44 (0)20 7905 2358
email: [log in to unmask]

-------------------------------------------------------------------
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