This function simulates an observation process. It takes sim_results
object
generated by sim
function and uses Virtual Ecologist approach on
the N_map
component of this object. As a result a data.frame
with
"observed" abundances is returned.
Arguments
- sim_data
sim_data
object frominitialise
containing simulation parameters- sim_results
sim_results
object; returned bysim
function- type
character vector of length 1; describes the sampling type (case-sensitive):
"random_one_layer" - cells from which the population numbers will be sampled are selected randomly; selected cells will be the same for all time steps
"random_all_layers" - cells from which the abundance will be sampled are selected randomly; a new set of cells will be selected for each time step
"from_data" - cells for which abundance will be sampled are provided by the user in a
data.frame
with three columns: "x", "y" and "time_step""monitoring_based" - cells from which abundance will be sampled are provided by the user in a matrix object with two columns: "x" and "y"; abundance from given cell is then sampled by different virtual observers in different time steps; whether a survey will be made by the same observer for several years and whether it will not be made at all is defined using a geometric distribution (
rgeom
)
- obs_error
character vector of length 1; name of the distribution defining the observation process: "
rlnorm
" (the log normal distribution) or "rbinom
" (the binomial distribution)- obs_error_param
numeric vector of length 1; standard deviation (on a log scale) of the random noise in observation process generated from the log-normal distribution (
rlnorm
) or probability of detection (success) when the binomial distribution ("rbinom
") is used- ...
other necessary internal parameters:
prop
numeric vector of length 1; proportion of cells to be sampled (default
prop = 0.1
); used whentype = "random_one_layer" or "random_all_layers"
,points
data.frame
ormatrix
with 3 named numeric columns ("x", "y" and "time_step") containing coordinates and time steps from which observations should be obtained; used whentype = "from_data"
,cells_coords
data.frame
ormatrix
with 2 named columns: "x" and "y"; survey plots coordinates; used whentype = "monitoring_based"
prob
numeric vector of length 1; a parameter defining the shape of -
rgeom
distribution - it defines whether an observation will be made by the same observer for several years and whether it will not be made at all (defaultprob = 0.3
); used whentype = "monitoring_based"
progress_bar
logical vector of length 1; determines if progress bar for observational process should be displayed (default
progress_bar = FALSE
); used whentype = "monitoring_based"
Value
data.frame
object with geographic coordinates, time steps,
estimated abundances, including observation error (if obs_error_param
is
provided) and observer identifiers (if type = "monitoring_based"
)
Examples
if (FALSE) {
library(terra)
n1_small <- rast(system.file("input_maps/n1_small.tif", package = "rangr"))
K_small <- rast(system.file("input_maps/K_small.tif", package = "rangr"))
# prepare data
sim_data <- initialise(
n1_map = n1_small,
K_map = K_small,
r = log(2),
rate = 1 / 1e3
)
sim_1 <- sim(obj = sim_data, time = 110, burn = 10)
# 1. random_one_layer
sample1 <- get_observations(
sim_data,
sim_1,
type = "random_one_layer",
prop = 0.1
)
# 2. random_all_layers
sample2 <- get_observations(
sim_data,
sim_1,
type = "random_all_layers",
prop = 0.15
)
# 3. from_data
sample3 <- get_observations(
sim_data,
sim_1,
type = "from_data",
points = observations_points
)
# 4. monitoring_based
# define observations sites
all_points <- xyFromCell(sim_data$id, cells(sim_data$K_map))
sample_idx <- sample(1:nrow(all_points), size = 20)
sample_points <- all_points[sample_idx, ]
sample4 <- get_observations(
sim_data,
sim_1,
type = "monitoring_based",
cells_coords = sample_points,
prob = 0.3,
progress_bar = TRUE
)
# 5. noise "rlnorm"
sample5 <- get_observations(sim_data,
sim_1,
type = "random_one_layer",
obs_error = "rlnorm",
obs_error_param = log(1.2)
)
# 6. noise "rbinom"
sample6 <- get_observations(sim_data,
sim_1,
type = "random_one_layer",
obs_error = "rbinom",
obs_error_param = 0.8
)
}