
Predict bird distributions conditioned on known locations
Source:R/predict_between.R
predict_between.Rdpredict_between() computes marginal probability distributions at each
timestep conditioned on observed locations at specific times, using a
Hidden Markov Model forward-backward algorithm. Use predict_between()
to produce predictions of where birds were at intermediate times when
you have information about their locations or distributions at two
or more points in time.
Arguments
- bf
A BirdFlow object.
- x_coord, y_coord
Parallel numeric vectors of observed x and y coordinates (in the model's CRS). Must be provided together with
date. Converted internally to indicator (one-hot) potentials. Cannot be used together withpotentials.- date
When using
x_coord/y_coord: a parallel vector of dates corresponding to each observation. When usingpotentials: a vector of dates corresponding to the columns ofpotentials(alternative to column names). Accepts any format recognized bylookup_timestep(): date strings ("2023-03-29"),Dateobjects, numeric timestep indices, or"t1"-style strings.- potentials
An
n_active(bf)xn_obsmatrix of soft observation potentials. Each column is a non-negative vector representing the observation likelihood at a given timestep. Timestep association is via column names or thedateargument (exactly one required). Cannot be used together withx_coord/y_coord.- ...
Arguments passed on to
lookup_timestep_sequenceseasona season name, season alias, or "all". See
lookup_season_timesteps()for options.startThe starting point in time specified as a timestep, character date, or date object.
endThe ending point in time as a date or timestep.
directionEither "forward" or "backward" defaults to
"forward"if not processing dates. If using date inputdirectionis optional and is only used to verify the direction implicit in the dates.season_bufferOnly used with
seasoninput.season_bufferis passed tolookup_season_timesteps()and defaults to 1; it is the number of timesteps to extend the season by at each end.n_stepsAlternative to
endThe end will ben_stepsaway fromstartindirection; and the resulting sequence will haven_steptransitions andn_steps + 1timesteps.
Value
A matrix of dimensions n_active(bf) x n_query_timesteps of
marginal probability distributions p(x_t | observations), one column per
timestep. Same format as predict(). The log-likelihood of the
observations is stored as attribute log_z.
See also
predict() for predictions from a single point in time,
route_between() for creating routes from the same inputs
as predict_between().
Examples
bf <- BirdFlowModels::amewoo
xy <- latlon_to_xy(lat = c(30.5, 45.5), lon = c(-91.5, -68.5), bf)
distr <- predict_between(bf,
x_coord = xy$x, y_coord = xy$y,
date = c("2023-02-15", "2023-05-01"))
plot_distr(distr, bf, dynamic_scale = TRUE)