Detection in space

What you look and where you look.

Vincent B and Andrew true
06-15-2022
curve(exp(-.2*(x)^2), xlim = c(-5, 5))
env <- seq(from = -6, to = 6, length.out = 100)
prob_occ_1d <- exp(-.2*(env)^2)
y <- rbinom(100, 1, prob = prob_occ_1d)

plot(env, y)

library(tidyverse)
env_grid <- expand_grid(x = env,
            y = env) |> 
  mutate(prob_occ = exp(-.2*(x)^2) *  exp(-.2*(y)^2))

env_grid |> 
  ggplot(aes( x = x, y = y, fill = prob_occ)) + geom_raster()

env_sampling <- env_grid |> 
  mutate(presabs = rbinom(n = nrow(env_grid), size = 1, prob = prob_occ),
         is_samp = rbinom(n = nrow(env_grid), size = 1, prob = .1))

env_sampling |> 
  ggplot(aes(x = x, y = y, fill = presabs)) + geom_raster() + 
  geom_point(col = "red", data = env_sampling |> 
               filter(is_samp == 1))

Sample, but keep effort the same!

nsamp <- 40
randsamp <- sample(1:nrow(env_sampling), size = 100, replace = FALSE)

env_samp_effort_control <- env_sampling |> 
  rownames_to_column("rownum") |> 
  mutate(is_samp_better = as.numeric(rownum %in% randsamp))

env_samp_effort_control |>
  ggplot(aes(x = x, y = y, fill = presabs)) + 
  geom_raster() + 
  geom_point(col = "red", data = env_samp_effort_control |> 
               filter(is_samp_better == 1))

sample NEGATIVELY correlated with the environment (birds that like deep forest)

nsamp <- 40
inverse_samp <- sample(1:nrow(env_sampling), size = 100, replace = FALSE,
                   prob = 1-env_samp_effort_control$prob_occ)

env_inverse <- env_samp_effort_control |> 
  mutate(inverse_samp = as.numeric(rownum %in% inverse_samp))

env_inverse |> 
  ggplot(aes(x = x, y = y, fill = presabs)) + 
  geom_raster() + 
  geom_point(col = "red", data = env_inverse |> 
               filter(inverse_samp == 1))