createACS | R Documentation |
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.
createACS(popdata, n1, yvar, criterion = 0, seed = NA, initsample = NA)
popdata |
A data frame providing information about the population to be sampled. Required columns include geographic coordinate columns |
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 |
seed |
Optional. An integer to feed to |
initsample |
Optional. A data frame that includes geographic coordinate columns |
A restricted adaptive cluster sample.
thompson1990adaptiveACSampling
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.