View source: R/get_observations.R
get_observations | R Documentation |
This function simulates an observation process. It accepts the sim_results
object, which is generated by the sim
function, and applies the virtual
ecologist approach on the N_map
component of the object. The function
returns a data.frame
with the 'observed' abundances.
get_observations(
sim_data,
sim_results,
type = c("random_one_layer", "random_all_layers", "from_data", "monitoring_based"),
obs_error = c("rlnorm", "rbinom"),
obs_error_param = NULL,
...
)
sim_data |
|
sim_results |
|
type |
character vector of length 1; describes the sampling type (case-sensitive):
|
obs_error |
character vector of length 1; type of the distribution
that defines the observation process: " |
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 ( |
... |
other necessary internal parameters:
|
data.frame
object with geographic coordinates, time steps,
estimated abundance, observation error (if obs_error_param
is
provided), and observer identifiers (if type = "monitoring_based"
). If type = "from_data"
, returned object is sorted in the same order as the input points
.
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(unwrap(sim_data$id), cells(unwrap(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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.