View source: R/drafts/createRACS.R View source: R/createRACS_flex.R
createRACS | 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.
The criterion value can be set with the criterion
argument, which defaults to zero. Cluster sampling is restricted by the argument, f_max
.
createRACS( popdata, n1, yvar, criterion = 0, seed = NA, initsample = NULL, f_max = 2 )
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 |
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). |
A restricted adaptive cluster sample.
saubyadaptiveACSampling
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.