Interpolate GPS locations at a set time interval using a continuous time correlated random walk (ctcrw) model
ctcrw_interpolation.Rd
This function is a wrapper for momentuHMM::crawlWrap(), which uses the crawl package to fit ctcrw model to GPS tracks at a user-defined time interval. The function is currently designed to handle GPS data from central place foraging birds. It takes tracking data, where trips have been identified and classified using OPPTools::opp_get_trips(). The function returns a list with four objects: (1) original tracking data (as SPDF), (2) colony location (as SPDF), (3) interpolated locations (as SPDF), and (4) a list of CRAWL fits for each trip. All spatial objects are in the same custom Lambert equal area projection centered on the colony.
Usage
ctcrw_interpolation(
data,
site,
type,
timestep,
interpolateGaps = TRUE,
showPlots = TRUE,
plotsPerPage = 4,
theta = c(8, 2),
quiet = TRUE
)
Arguments
- data
Trip data ouptut from OPPTools::opp_get_trips().
- site
Vector containing coordinates of the study site, in the same format as site information returned by OPPtools::opp2KBA or track2KBA::move2KBA.
- type
List indicating the types of trips to include in interpolation. Possible values are: 'Complete', 'Incomplete', 'Gappy', and 'Non-trip'. Default is 'Complete'.
- timestep
string indicating time step for track interpolation, eg. '10 min', '1 hour', '1 day'
- showPlots
TRUE/FALSE should plots of interpolated tracks against original data be produced
- plotsPerPage
Numeric indicating the number of individuals to include in a single plot. Defaults to 4.
- theta
starting values for ctcrw parameter optimization, see ?crawl::crwMLE for details
Examples
my_data <- opp_download_data(study = c(1247096889),login = NULL, start_month = NULL,
end_month = NULL,season = NULL)
#> Warning: 0 location(s) is/are removed by removeDuplicatedTimestamps
my_track2kba <- opp2KBA(data = my_data)
my_trips <- opp_get_trips(data = my_track2kba, innerBuff = 5, returnBuff = 20,
duration = 2, gapLimit = 100, gapTime = 2, gapDist = 5,
showPlots = TRUE)
#> Registered S3 methods overwritten by 'adehabitatMA':
#> method from
#> print.SpatialPixelsDataFrame sp
#> print.SpatialPixels sp
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Use back arrow in plot pane to browse all plots
my_interp <- ctcrw_interpolation(data = my_trips,
site = my_track2kba$site,
type = c('Complete','Incomplete','Gappy'),
timestep = '10 min',
interpolateGaps = T,
showPlots = T,
plotsPerPage = 2,
theta = c(8,2)
)
#> crawl 2.2.1 (2018-09-12)
#> Demos and documentation can be found at our new GitHub repository:
#> https://dsjohnson.github.io/crawl_examples/
#> Loading required package: foreach
#> Loading required package: rngtools
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Warning: CRS object has comment, which is lost in output; in tests, see
#> https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
#> Beginning SANN initialization ...
#> Beginning likelihood optimization ...
#> Use back arrow in plot pane to browse all plots