createACS: Create an Adaptive Cluster Sample

View source: R/createACS.R

createACSR Documentation

Create an 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.

Usage

createACS(popdata, n1, yvar, criterion = 0, seed = NA, initsample = NA)

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.

Value

A restricted adaptive cluster sample.

References

\insertRef

thompson1990adaptiveACSampling

Examples

library(ggplot2)
data(Thompson1990Fig1Pop)
data(Thompson1990Figure1Sample)
# Create ACS sample, seed=9
# - in the dataframe "Thompson1990Fig1Pop", the variable of interest $y$ is 
#        "y_value"
# - any "y_value" greater than the criterion 0 will trigger cluster sampling
popdata = Thompson1990Fig1Pop
seed = 9
n1 = 10
yvar = "y_value"
criterion = 0
Z = createACS(popdata, n1, yvar, criterion, seed)
# plot ACS sample and population from which sampled was collected. In the 
#        plot, the open squares correspond to population units that were 
#        sampled
ggplot() +
geom_point(
data=Thompson1990Fig1Pop,
aes(x, y, size=y_value,shape=factor(y_value))) +
scale_shape_manual(values=c(1, rep(16, length(2:13)))) +
geom_point(data=Z, aes(x,y), shape=0, size=7)
# Create another ACS, seed=26
# - In this example, no units satisfy the criterion and thus cluster sampling
#        does not occur
Z = createACS(
popdata=Thompson1990Fig1Pop,
seed=26,
n1=10,
yvar="y_value",
criterion=0
)
# plot ACS sample and population from which sampled was collected
ggplot() +
geom_point(
data=Thompson1990Fig1Pop,
aes(x, y, size=factor(y_value), shape=factor(y_value))
) +
scale_shape_manual(values=c(1, rep(16, length(2:13)))) +
geom_point(data=Z, aes(x,y), shape=0, size=7)

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