Determine how many samples to allocate within strata.

## Usage

calculate_allocation(
sraster,
nSamp,
allocation = "prop",
weights = NULL,
mraster = NULL,
existing = NULL,
force = FALSE
)

## Arguments

sraster

spatRaster. Stratification raster to be used for sampling.

nSamp

Numeric. Number of desired samples.

allocation

Character. Allocation algorithm to be used. Either prop (default) for proportional allocation, optim for optimal allocation (equal sampling cost), equal for equal number of samples (defined by nSamp) for each strata, or "manual" for user defined strata weights defined using weights.

weights

Numeric. Only applicable when allocation = "manual". Vector of weights where sum(weights) == 1. Vector length must be equal to the number of unique strata where the first numeric value corresponds to stratum 1, second stratum 2 etc.

mraster

spatRaster. ALS metric raster. Required when allocation = optim.

existing

sf 'POINT' or data.frame. Existing plot network.

force

Logical. Default = FALSE - force nSamp to be exactly the user defined value in cases where nSamp and sraster strata count are not equally divisible. Additional samples often need to be allocated or removed based on rounding differences resulting from proportional differences between nSamp and strata coverages in sraster. In these instances samples are either added to strata with the lowest number of samples or are removed from strata with the highest number of samples. Has no effect when existing is provided.

## Value

Returns a data.frame of:

• strata - Strata ID.

• total - Number of samples to be allocated. Values correspond to under representation (samples needed; positive value) or over representation (too many samples; negative value) based on the nSamp provided.

• need - Required samples per strata based on allocation method. Rounded.

## References

Gregoire, T.G., & Valentine, H.T. (2007). Sampling Strategies for Natural Resources and the Environment (1st ed.). Chapman and Hall/CRC. https://doi.org/10.1201/9780203498880

Other calculate functions: calculate_allocation_existing(), calculate_coobs(), calculate_distance(), calculate_pcomp(), calculate_pop(), calculate_representation(), calculate_sampsize()

## Author

Tristan R.H. Goodbody

## Examples

if (FALSE) {
#--- Load strata raster and existing samples---#
r <- system.file("extdata", "sraster.tif", package = "sgsR")
sr <- terra::rast(r)

e <- system.file("extdata", "existing.shp", package = "sgsR")