Vector arguments of custom functions based on the GraphVectortemp1 template are not passed correctly.
*Operating System: Windows XP
*OpenBUGS version: User-compiled from revision 397
I attempted to develop BUGS functions (logical nodes) with vector arguments based on the GraphVectortemp1 template. When I attempt to use such functions in a BUGS model I find that the vector arguments are often passed incorrectly. This happens when the vector argument has the following properties:
The argument is a subset of a larger vector in the BUGS model, e.g., argument = x[1:n] when x is a vector with length > n.
The first element of the vector argument is also the first element of the entire BUGS vector, e.g., x[1:n] as opposed to x[m:n] where m > 1.
When those conditions are true the entire BUGS vector gets passed to the function instead of the specified subvector. On the other hand if the vector argument is say x[m:n] where m > 1, the correct subvector is passed. In other words a vector of length n - m + 1 is passed.
Source code, BUGS model and script to produce bug
The behavior described above is illustrated with the attached files:
External.odc: This is the BugsExternal module revised to define the vectorIdentity and vectorDim2 functions. Either replace the current External.odc file in Bugs/Mod or edit the existing file to add the definitions of vectorIdentity and vectorDim2. Compile with BlackBox.
vectorIdentityTest.txt: This is a simple BUGS model file that calls the vectorIdentity and vectorDim2 functions to illustrate the problem.
vectorIdentityTestScript.txt: A BUGS script to run the vectorIdentityTest model.
If you run the script in its current form you will see that "test" should represent the length of the second vector argument "x2[1:6]" and that it incorrectly indicates it has length = 12. In the script if you uncomment the line "#samplesSet(test2)" and you rerun it, you get an "index out of range" trap and the trap window shows that the argument has an incorrect length.
- Assigned to:
- Requested by: Bill Gillespie
- Status: Resolved. Thanks to Andrew Thomas for setting me straight on the appropriate way to work with the vector arguments, e.g., using node.size rather than LEN.