createRACS: Create a Restricted Adaptive Cluster Sample

View source: R/drafts/createRACS.R View source: R/createRACS_flex.R

createRACSR Documentation

Create a Restricted Adaptive Cluster Sample

Description

Select a restricted adaptive cluster sample from a dataframe containing columns indicating the spatial coordinates of each unit (x and y) as well as the variable of interest, provided to the function via the yvar argument. Cluster sampling is initiated for primary units in which the value of the variable of interest exceeds the criterion value. The criterion value can be set with the criterion argument, which defaults to zero. Cluster sampling is restricted by the argument, f_max.

Usage

createRACS(
  popdata,
  n1,
  yvar,
  criterion = 0,
  seed = NA,
  initsample = NULL,
  f_max = 2
)

Arguments

popdata

A data frame providing information about the population to be sampled. Required columns include geographic coordinate columns x and y, as well as a column containing the variable of interest, whose name is provided to the function via the yvar argument.

n1

An integer giving the initial sample size (e.g., a simple random sample).

yvar

A string giving the name of the variable of interest, y, in the supplied dataframe popdata. This variable determines the condition under which adaptive cluster sampling takes place. In the dataframe $popdata$ this variable y must be numeric.

criterion

Numeric threshold value of the variable of interest y (whose name in the dataframe $popdata$ is supplied via the yvar argument) that initiates ACS. Defaults to 0 (ie., anything greater than 0 initiates adaptive cluster sampling).

seed

Optional. An integer to feed to set.seed() so that the sampling is reproducible.

initsample

Optional. A data frame that includes geographic coordinate columns x and y of the initial sample. The defaults is NA, which results in the initial sample being selected according to simple random sampling without replacement.

f_max

The maximum number of expanding sets of adjacent units surveyed per primary unit in the adaptive phase of ACS. For more information, see Sauby and Christman (in prep).

Value

A restricted adaptive cluster sample.

References

\insertRef

saubyadaptiveACSampling

Examples

library(ggplot2)
seed=3
n1=5
y_variable = "y_value"
f_max = 3
# cluster sampling not triggered, only y_values of zero sampled
Z = createRACS(
	popdata=lambdap_5_tau_1, 
	n1=n1, 
	yvar=y_variable, 
	seed=seed, 
	f_max=f_max
)

ggplot() +
   geom_point(
      data=lambdap_5_tau_1,
      aes(x,y, size=y_value)
   ) +
   geom_point(data=Z, aes(x,y), shape = 0, size=7) 

ksauby/ACS documentation built on Aug. 18, 2022, 3:33 a.m.