cont_cdftest {spsurvey} | R Documentation |
Cumulative distribution function (CDF) inference for a probability survey
Description
This function organizes input and output for conducting inference regarding cumulative distribution functions (CDFs) generated by a probability survey. For every response variable and every subpopulation (domain) variable, differences between CDFs are tested for every pair of subpopulations within the domain. Data input to the function can be either a single survey or multiple surveys (two or more). If the data contain multiple surveys, then the domain variables will reference those surveys and (potentially) subpopulations within those surveys. The inferential procedures divide the CDFs into a discrete set of intervals (classes) and then utilize procedures that have been developed for analysis of categorical data from probability surveys. Choices for inference are the Wald, adjusted Wald, Rao-Scott first order corrected (mean eigenvalue corrected), and Rao-Scott second order corrected (Satterthwaite corrected) test statistics. The default test statistic is the adjusted Wald statistic. The input data argument can be either a data frame or a simple features (sf) object. If an sf object is used, coordinates are extracted from the geometry column in the object, arguments xcoord and ycoord are assigned values "xcoord" and "ycoord", respectively, and the geometry column is dropped from the object.
Usage
cont_cdftest(
dframe,
vars,
subpops = NULL,
surveyID = NULL,
siteID = "siteID",
weight = "weight",
xcoord = NULL,
ycoord = NULL,
stratumID = NULL,
clusterID = NULL,
weight1 = NULL,
xcoord1 = NULL,
ycoord1 = NULL,
sizeweight = FALSE,
sweight = NULL,
sweight1 = NULL,
fpc = NULL,
popsize = NULL,
vartype = "Local",
jointprob = "overton",
testname = "adjWald",
nclass = 3
)
Arguments
dframe |
Data frame containing survey design variables, response variables, and subpopulation (domain) variables. |
vars |
Vector composed of character values that identify the
names of response variables in the |
subpops |
Vector composed of character values that identify the
names of subpopulation (domain) variables in the |
surveyID |
Character value providing name of the survey ID variable in
the |
siteID |
Character value providing name of the site ID variable in
the |
weight |
Character value providing name of the survey design weight
variable in the |
xcoord |
Character value providing name of the x-coordinate variable in
the |
ycoord |
Character value providing name of the y-coordinate variable in
the |
stratumID |
Character value providing name of the stratum ID variable in
the |
clusterID |
Character value providing the name of the cluster
(stage one) ID variable in the |
weight1 |
Character value providing name of the stage one weight
variable in the |
xcoord1 |
Character value providing the name of the stage one
x-coordinate variable in the |
ycoord1 |
Character value providing the name of the stage one
y-coordinate variable in the |
sizeweight |
Logical value that indicates whether size weights should be
used during estimation, where |
sweight |
Character value providing the name of the size weight variable
in the |
sweight1 |
Character value providing name of the stage one size weight
variable in the |
fpc |
Object that specifies values required for calculation of the finite population correction factor used during variance estimation. The object must match the survey design in terms of stratification and whether the design is single-stage or two-stage. For an unstratified design, the object is a vector. The vector is composed of a single numeric value for a single-stage design. For a two-stage unstratified design, the object is a named vector containing one more than the number of clusters in the sample, where the first item in the vector specifies the number of clusters in the population and each subsequent item specifies the number of stage two units for the cluster. The name for the first item in the vector is arbitrary. Subsequent names in the vector identify clusters and must match the cluster IDs. For a stratified design, the object is a named list of vectors, where names must match the strata IDs. For each stratum, the format of the vector is identical to the format described for unstratified single-stage and two-stage designs. Note that the finite population correction factor is not used with the local mean variance estimator. Example fpc for a single-stage unstratified survey design:
Example fpc for a single-stage stratified survey design:
Example fpc for a two-stage unstratified survey design:
Example fpc for a two-stage stratified survey design:
|
popsize |
Object that provides values for the population argument of the
Example popsize for calibration:
Example popsize for post-stratification using a data frame:
Example popsize for post-stratification using a table:
Example popsize for post-stratification using an xtabs object:
|
vartype |
Character value providing the choice of the variance
estimator, where |
jointprob |
Character value providing the choice of joint inclusion
probability approximation for use with Horvitz-Thompson and Yates-Grundy
variance estimators, where |
testname |
Name of the test statistic to be reported in the output
data frame. Choices for the name are: |
nclass |
Number of classes into which the CDFs will be divided
(binned), which must equal at least |
Value
Data frame of CDF test results for all pairs of subpopulations
within each population type for every response variable. The data frame
includes the test statistic specified by argument testname
plus its
degrees of freedom and p-value.
Author(s)
Tom Kincaid Kincaid.Tom@epa.gov
See Also
cdf_plot
for visualizing CDF plots
cont_cdfplot
for making CDF plots output to pdfs
Examples
n <- 200
mysiteID <- paste("Site", 1:n, sep = "")
dframe <- data.frame(
siteID = mysiteID,
wgt = runif(n, 10, 100),
xcoord = runif(n),
ycoord = runif(n),
stratum = rep(c("Stratum1", "Stratum2"), n / 2),
Resource_Class = sample(c("Agr", "Forest", "Urban"), n, replace = TRUE)
)
ContVar <- numeric(n)
tst <- dframe$Resource_Class == "Agr"
ContVar[tst] <- rnorm(sum(tst), 10, 1)
tst <- dframe$Resource_Class == "Forest"
ContVar[tst] <- rnorm(sum(tst), 10.1, 1)
tst <- dframe$Resource_Class == "Urban"
ContVar[tst] <- rnorm(sum(tst), 10.5, 1)
dframe$ContVar <- ContVar
myvars <- c("ContVar")
mysubpops <- c("Resource_Class")
mypopsize <- data.frame(
Resource_Class = rep(c("Agr", "Forest", "Urban"), rep(2, 3)),
stratum = rep(c("Stratum1", "Stratum2"), 3),
Total = c(2500, 1500, 1000, 500, 600, 450)
)
cont_cdftest(dframe,
vars = myvars, subpops = mysubpops, siteID = "siteID",
weight = "wgt", xcoord = "xcoord", ycoord = "ycoord",
stratumID = "stratum", popsize = mypopsize, testname = "RaoScott_First"
)