full_BASS_run: A full BASS run

View source: R/BASS_full_run.R

full_BASS_runR Documentation

A full BASS run

Description

A full BASS run

Usage

full_BASS_run(
  land_hex,
  num_runs,
  n_samples,
  costs = NULL,
  hex_id = hex_id,
  stratum_id = NULL,
  omit_flag = NULL,
  non_random_set = NULL,
  benefit_weight = 0.5,
  land_cover_weights = NULL,
  return_grts = FALSE,
  crs = 4326,
  coords = c("lon", "lat"),
  seed = NULL,
  quiet = FALSE,
  ...
)

Arguments

land_hex

(Spatial) Data frame. Land Cover data by hexagon. If non-spatial, will be converted to spatial sf data frame using the crs and coords arguments. Requires columns identifying the Hex ID as well as the Stratum ID (see hex_id and stratum_id respectively).

num_runs

Numeric. Number of times to draw random samples.

n_samples

Numeric. Number of samples to draw in each run.

costs

Data frame. Costs for each hexagon in a RawCost format.

hex_id

Column. Identifies hexagon IDs (e.g., default hex_id).

stratum_id

Column. Identifies larger area (e.g., StudyAreaID or Province).

omit_flag

Column identifying hexes to omit (e.g., water hexes).

non_random_set

Character vector. hex_ids of hexagons to include as a non randomly selected set.

benefit_weight

Numeric. Weight assigned to benefit in the selection probabilities. 0.5 is equal weighting of cost and benefits. 1.0 is zero weighting to cost. Default 0.5.

land_cover_weights

Data frame. Proportional weights (weights column) for specific types of landcover (lc column). lc should correspond to the same landcover column names as the hex data.

return_grts

Logical. Return the spsurvey object(s).

crs

Numeric, character, or sf/sfc. Coordinate reference system. Must be valid input to sf::st_crs().

coords

Character vector. Names of the columns containing X and Y coordinates (default c("lon", "lat")).

seed

Numeric. Random seed to use for random sampling. Seed only applies to specific sampling events (does not change seed in the environment). NULL does not set a seed.

quiet

Logical. Whether to suppress progress messages.

...

Extra named arguments passed on to spsurvey::grts().

Value

Data frame of inclusion probabilities. Or, if return_grts = TRUE a list including the data frame of inclusion probabilities as well as the spsurvey grts sampling object.

Extra arguments

Extra named arguments for spsurvey::grts() can also be passed on via .... In particular, note that the default values for mindis (minimum distance between sites) is NULL, and maxtry (maximum attempts to try to obtain the minimum distance between sites) is 10.

Examples


# With example data psu_hexagons and psu_costs...

d <- full_BASS_run(
  land_hex = psu_hexagons,
  num_runs = 10,
  n_samples = 3,
  costs = psu_costs)

# Omit water hexes

d <- full_BASS_run(
  land_hex = psu_hexagons,
  num_runs = 10,
  n_samples = 3,
  costs = psu_costs,
  omit_flag = water)

# Keep grts objects

d <- full_BASS_run(
  land_hex = psu_hexagons,
  num_runs = 10,
  n_samples = 3,
  costs = psu_costs,
  return_grts = TRUE)

names(d)
d[["inclusion_probs"]]
d[["grts_output"]][[1]]

# Change spsurvey::grts() arguments

d <- full_BASS_run(
  land_hex = psu_hexagons,
  num_runs = 10,
  n_samples = 3,
  costs = psu_costs,
  mindis = 10, maxtry = 10)

d

dhope/BASSr documentation built on April 12, 2024, 9:54 p.m.