simulation_function_p: Primary function for simulating & analysing datasets that are...

Description Usage Arguments Value Examples

Description

This function is one of the master functions in this package. It simulates and analyzes a single dataset that is over-dispersed in detection probability, det_prob. To do this many times, use an apply function. It's currently simplified and assumes constant abundance, detection, and transect length. It does not (yet) simulate goodness-of-fit metrics. It simulates both point count and distance data and analyses both datasets using both unmarked and optim.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
simulation_function_p(
  n_sites = 50,
  n_samps = 6,
  lambda = 10,
  mean_det_prob = 0.42,
  sigma_beta_dist_p = 0.01,
  alpha = NA,
  beta = NA,
  W = 20,
  reps_to_analyze = 3,
  return = "results",
  savefilename = file.path("set 1", "datasets", "data")
)

Arguments

n_sites

number of sites (transects)

n_samps

number of samples (replicates) per site

lambda

mean abundance at every site (single draw per site that stays constant across samples)

mean_det_prob

average probability of being observed. Each simulation will draw a random detection probability from a beta distribution with a mean of mean_det_prob

sigma_beta_dist_p

sigma on a beta distribution for the realized detection parameter. It's recommended to keep this below ~ 0.15. Above that the beta distribution becomes bimodal with modes near 0 and 1.

alpha

(optional) parameter of the beta distribution. It's recommended NOT to specify this parameter. Just specify the mean and sigma, and this value will be calculated to match the given mean and sigma.

beta

(optional) parameter of the beta distribution. It's recommended NOT to specify this parameter. Just specify the mean and sigma, and this value will be calculated to match the given mean and sigma.

W

transect half-width (meters)

reps_to_analyze

the number of samples/replicates to analyze. If NA, it will analyse all replicates in the data.

return

What to return from the function call. Currently the only option is 'results'. May change this to only analyze simulated goodness-of-fit metrics.

savefilename

The simulated datasets and results ARE saved to file (currently not optional). This provides the path and filename for saving the intermediate steps in the analysis.

Value

if everything works well, it returns a data.frame with the results of simulating a single dataset, analyzing it in 4 ways, and calculating randomized quantile residuals a la Knape et al. 2018. It also saves a list with the simulated dataset, dataframe of results (minus rqr residual info), and the actual rqr residuals to a savefilename inside the folder path 'working directory'/results/Scenario 3/savefilename. If there is an error, the function returns NA and also saves a file to 'working directory'/Scenario 3/set x/errors with the simulated dataset and the results data.frame but no rq-residuals (it's basically assumed that the rq-residuals were the source of the error.) Similarly, with a warning the function returns the results data.frame and also saves a file to 'working directory'/Scenario 3/set x/warnings with the simulated dataset and the results data.frame but no rq-residuals (it's basically assumed that the rq-residuals were the source of the error.) The user will have to go back and try to calculate rq-residuals from the output later.

Examples

1

philipshirk/nmmsims documentation built on Feb. 26, 2020, 11:27 a.m.