<span class="ul-threaded" style="margin: 0.5em 0pt 0pt -20px;"><span class="text-cell"> 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.
<br><br>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".
<br><br><br>################################################################################
<br>## Run the Fortran routine repeatedly with identical data
<br>## - all required objects are in workspace "BBMM_BUG.RData" -
<br><br>require(BBMM)
<br><br>par(mfrow=c(2,2))
<br><br><br>repeat {
<br> ans <- .Fortran("BBMM", as.integer(n.locs),
as.integer(grid.size),
<br> as.double(time.lag), as.double(T.Total), as.double(x),
<br> as.double(y), as.double(BMvar), as.double(location.error),
<br> as.double(area.grid$x), as.double(area.grid$y),
as.double(time.step),
<br> as.double(probability), PACKAGE = "BBMM")
<br><br> if(!sum(ans[[12]])=="NaN") { hist(ans[[12]]) } else { break }
<br>}
<br>#################################################################################
<br><br><br>Tyler
</span></span><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}</style>