[R-sig-Geo] potential BUG in BBMM
Tyler Dean Rudolph
prairie.picker at gmail.com
Wed Jul 14 17:15:42 CEST 2010
In fact I have been in fairly regular communication with Ryan Nielson
about this, but I don't get the impression he has a lot of time to
devote to resolving it. So far I have managed to circumvent all the
potential problems he has suggested, and I have narrowed it down to
this Fortran loop. Now he seems of the mind that it is a problem with
R - which I suppose is possible? - but whether it is the Fortran code,
R, or something else I don't believe I have the tools to assess the
problem any further. I am certainly not imagining the problem, as
I've mentioned, but if somebody more knowledgeable could at least
reproduce it we might be somewhere closer to a solution. In the
meantime I have suggested that BBMM be used with caution, especially
in big loops with large data sets, but Ryan hasn't commented on this,
and at any rate I wouldn't mind getting a third or fourth opinion.
Tyler
On 2010-07-14, at 5:33, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> 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