[R-sig-Geo] potential BUG in BBMM

Roger Bivand Roger.Bivand at nhh.no
Wed Jul 14 11:33:07 CEST 2010


On Tue, 13 Jul 2010, Tyler Dean Rudolph wrote:

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

Have you also contacted the package authors directly? They would be the 
best point of entry here, I think.

Roger

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

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list