[R-sig-Geo] potential BUG in BBMM

Tyler Dean Rudolph tylerdeanrudolph at gmail.com
Tue Jul 13 23:23:40 CEST 2010


     I've been constructing utilization distributions for 63 animal movement
trajectories using a Brownian bridge movement model with BBMM.  I started
noticing after running the routine numerous times at different resolutions
that certain UDs would be grossly wrong, meaning instead of returning a
strongly negative exponential distribution of probabilities (UD$probability)
that sums to 1, there might be two big modes in opposite places, or negative
probability values, or simply "NaN" across the board.  I have found this
problem on Mac, Linux, and Windows machines in various versions of R
(including the most recent), and I was hoping someone in the R community
would be able to verify this and perhaps speculate on why this is occurring.


The problem appears to originate either 1) in the FORTRAN code that
estimates BMVar and calculates the BBMM, or 2) in the way R handles its
operation.  I've broken down BBMM into its essential parts, and in the
attached environment are all of the objects necessary to run the FORTRAN
code.  I have set it up in a loop here so it continually estimates a UD on
the same data then and produces a histogram, which I have found to be most
revealing in identifying problems.  If the code stops running it's because
the result was all "NaN".  If you run the loop repeatedly you may find, as I
have, that while the results may initially appear more-or-less consistent,
at other moments they will change, sometimes gradually, and sometimes
quickly.  If you are looking at it and it is not changing, I encourage you
to remove all objects, close and reopen R, reload the workspace and run the
same loop again.  If you do this numerous times you should eventually see
unusual results, meaning inconsistent estimation, or wacky probability
distributions, or "NaN".


################################################################################

##  Run the Fortran routine repeatedly with identical data
##  - all required objects are in workspace "BBMM_BUG.RData" -

require(BBMM)

par(mfrow=c(2,2))


repeat {
        ans <- .Fortran("BBMM", as.integer(n.locs), as.integer(grid.size),
        as.double(time.lag), as.double(T.Total), as.double(x),
        as.double(y), as.double(BMvar), as.double(location.error),
        as.double(area.grid$x), as.double(area.grid$y),
as.double(time.step),
        as.double(probability), PACKAGE = "BBMM")

    if(!sum(ans[[12]])=="NaN") { hist(ans[[12]]) } else { break }
}
#################################################################################



Tyler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100713/25434b80/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BBMM_BUG.RData
Type: application/octet-stream
Size: 2896 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100713/25434b80/attachment.obj>


More information about the R-sig-Geo mailing list