change_analysis {spsurvey} | R Documentation |
Change analysis
Description
This function organizes input and output for the estimation of change between two
samples (for categorical and continuous variables). The analysis data,
dframe
, 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
change_analysis(
dframe,
vars_cat = NULL,
vars_cont = NULL,
test = "mean",
subpops = NULL,
surveyID = "surveyID",
survey_names = NULL,
siteID = "siteID",
weight = "weight",
revisitwgt = FALSE,
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",
conf = 95,
All_Sites = FALSE
)
Arguments
dframe |
Data to be analyzed (analysis data). A data frame or
|
vars_cat |
Vector composed of character values that identify the
names of categorical response variables in |
vars_cont |
Vector composed of character values that identify the
names of continuous response variables in |
test |
Character string or character vector providing the location
measure(s) to use for change estimation for continuous variables. The
choices are |
subpops |
Vector composed of character values that identify the
names of subpopulation (domain) variables in |
surveyID |
Character value providing name of the survey ID variable in
|
survey_names |
Character vector of length two that provides the survey
names contained in the |
siteID |
Character value providing name of the site ID variable in
|
weight |
Character value providing name of the design weight
variable in |
revisitwgt |
Logical value that indicates whether each repeat visit
site has the same design weight in the two surveys, where
|
xcoord |
Character value providing name of the x-coordinate variable in
|
ycoord |
Character value providing name of the y-coordinate variable in
|
stratumID |
Character value providing name of the stratum ID variable in
|
clusterID |
Character value providing the name of the cluster
(stage one) ID variable in |
weight1 |
Character value providing name of the stage one weight
variable in |
xcoord1 |
Character value providing the name of the stage one
x-coordinate variable in |
ycoord1 |
Character value providing the name of the stage one
y-coordinate variable in |
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 |
sweight1 |
Character value providing name of the stage one size weight
variable in |
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 |
conf |
Numeric value providing the Gaussian-based confidence level. The default value
is |
All_Sites |
A logical variable used when |
Value
List of change estimates composed of four items:
(1) catsum
contains change estimates for categorical variables,
(2) contsum_mean
contains estimates for continuous variables using
the mean, (3) contsum_total
contains estimates for continuous
variables using the total, and (4) contsum_median
contains estimates for continuous
variables using the median. The items in the list will contain NULL
for estimates that were not calculated. Each data frame includes estimates
for all combinations of population Types, subpopulations within types,
response variables, and categories within each response variable (for
categorical variables and continuous variables using the median). Change
estimates are provided plus standard error estimates and confidence
interval estimates.
The catsum
data frame contains the following variables:
- Survey_1
first survey name
- Survey_2
second survey name
- Type
subpopulation (domain) name
- Subpopulation
subpopulation name within a domain
- Indicator
response variable
- Category
category of response variable
- DiffEst.P
proportion difference estimate (in %; second survey - first survey)
- StdError.P
standard error of proportion difference estimate
- MarginofError.P
margin of error of proportion difference estimate
- LCBxxPct.P
xx% (default 95%) lower confidence bound of proportion difference estimate
- UCBxxPct.P
xx% (default 95%) upper confidence bound of proportion difference estimate
- Estimate.U
total difference estimate (second survey - first survey)
- StdError.U
standard error of total difference estimate
- MarginofError.U
margin of error of total difference estimate
- LCBxxPct.U
xx% (default 95%) lower confidence bound of total difference estimate
- UCBxxPct.U
xx% (default 95%) upper confidence bound of total difference estimate
- nResp_1
sample size in the first survey
- Estimate.P_1
proportion estimate (in %) from the first survey
- StdError.P_1
standard error of proportion estimate from the first survey
- MarginofError.P_1
margin of error of proportion estimate from the first survey
- LCBxxPct.P_1
xx% (default 95%) lower confidence bound of proportion estimate from the first survey
- UCBxxPct.P_1
xx% (default 95%) upper confidence bound of proportion estimate from the first survey
- nResp_2
sample size in the second survey
- Estimate.U_1
total estimate from the first survey
- StdError.U_1
standard error of total estimate from the first survey
- MarginofError.U_1
margin of error of total estimate from the first survey
- LCBxxPct.U_1
xx% (default 95%) lower confidence bound of total estimate from the first survey
- UCBxxPct.U_1
xx% (default 95%) upper confidence bound of total estimate from the first survey
- Estimate.P_2
proportion estimate (in %) from the second survey
- StdError.P_2
standard error of proportion estimate from the second survey
- MarginofError.P_2
margin of error of proportion estimate from the second survey
- LCBxxPct.P_2
xx% (default 95%) lower confidence bound of proportion estimate from the second survey
- UCBxxPct.P_2
xx% (default 95%) upper confidence bound of proportion estimate from the second survey
- Estimate.U_2
total estimate from the second survey
- StdError.U_2
standard error of total estimate from the second survey
- MarginofError.U_2
margin of error of total estimate from the second survey
- LCBxxPct.U_2
xx% (default 95%) lower confidence bound of total estimate from the second survey
- UCBxxPct.U_2
xx% (default 95%) upper confidence bound of total estimate from the second survey
The contsum_mean
data frame contains the following variables:
- Survey_1
first survey name
- Survey_2
second survey name
- Type
subpopulation (domain) name
- Subpopulation
subpopulation name within a domain
- Indicator
response variable
- Statistic
value of percentile
- nResp
sample size at or below
Value
- DiffEst
mean difference estimate
- StdError
standard error of mean difference estimate
- MarginofError
margin of error of mean difference estimate
- LCBxxPct
xx% (default 95%) lower confidence bound of mean difference estimate
- UCBxxPct
xx% (default 95%) upper confidence bound of mean difference estimate
- nResp_1
sample size in the first survey
- Estimate_1
mean estimate from the first survey
- StdError_1
standard error of mean estimate from the first survey
- MarginofError_1
margin of error of mean estimate from the first survey
- LCBxxPct_1
xx% (default 95%) lower confidence bound of mean estimate from the first survey
- UCBxxPct_1
xx% (default 95%) upper confidence bound of mean estimate from the first survey
- nResp_2
sample size in the second survey
- Estimate_2
mean estimate from the second survey
- StdError_2
standard error of mean estimate from the second survey
- MarginofError_2
margin of error of mean estimate from the second survey
- LCBxxPct_2
xx% (default 95%) lower confidence bound of mean estimate from the second survey
- UCBxxPct_2
xx% (default 95%) upper confidence bound of mean estimate from the second survey
The contsum_total
data frame contains the following variables:
- Survey_1
first survey name
- Survey_2
second survey name
- Type
subpopulation (domain) name
- Subpopulation
subpopulation name within a domain
- Indicator
response variable
- Statistic
value of percentile
- nResp
sample size at or below
Value
- DiffEst
total difference estimate
- StdError
standard error of total difference estimate
- MarginofError
margin of error of total difference estimate
- LCBxxPct
xx% (default 95%) lower confidence bound of total difference estimate
- UCBxxPct
xx% (default 95%) upper confidence bound of total difference estimate
- nResp_1
sample size in the first survey
- Estimate_1
total estimate from the first survey
- StdError_1
standard error of total estimate from the first survey
- MarginofError_1
margin of error of total estimate from the first survey
- LCBxxPct_1
xx% (default 95%) lower confidence bound of total estimate from the first survey
- UCBxxPct_1
xx% (default 95%) upper confidence bound of total estimate from the first survey
- nResp_2
sample size in the second survey
- Estimate_2
total estimate from the second survey
- StdError_2
standard error of total estimate from the second survey
- MarginofError_2
margin of error of total estimate from the second survey
- LCBxxPct_2
xx% (default 95%) lower confidence bound of total estimate from the second survey
- UCBxxPct_2
xx% (default 95%) upper confidence bound of total estimate from the second survey
The contsum_median
data frame contains the following variables:
- Survey_1
first survey name
- Survey_2
second survey name
- Type
subpopulation (domain) name
- Subpopulation
subpopulation name within a domain
- Indicator
response variable
- Category
category of response variable
- DiffEst.P
proportion above or below median difference estimate (in %; second survey - first survey)
- StdError.P
standard error of proportion above or below median difference estimate
- MarginofError.P
margin of error of proportion above or below median difference estimate
- LCBxxPct.P
xx% (default 95%) lower confidence bound of proportion above or below median difference estimate
- UCBxxPct.P
xx% (default 95%) upper confidence bound of proportion above or below median difference estimate
- Estimate.U
total above or below median difference estimate (second survey - first survey)
- StdError.U
standard error of total above or below median difference estimate
- MarginofError.U
margin of error of total above or below median difference estimate
- LCBxxPct.U
xx% (default 95%) lower confidence bound of total above or below median difference estimate
- UCBxxPct.U
xx% (default 95%) upper confidence bound of total above or below median difference estimate
- nResp_1
sample size in the first survey
- Estimate.P_1
proportion above or below median estimate (in %) from the first survey
- StdError.P_1
standard error of proportion above or below median estimate from the first survey
- MarginofError.P_1
margin of error of proportion above or below median estimate from the first survey
- LCBxxPct.P_1
xx% (default 95%) lower confidence bound of proportion above or below median estimate from the first survey
- UCBxxPct.P_1
xx% (default 95%) upper confidence bound of proportion above or below median estimate from the first survey
- nResp_2
sample size in the second survey
- Estimate.U_1
total above or below median estimate from the first survey
- StdError.U_1
standard error of total above or below median estimate from the first survey
- MarginofError.U_1
margin of error of total above or below median estimate from the first survey
- LCBxxPct.U_1
xx% (default 95%) lower confidence bound of total above or below median estimate from the first survey
- UCBxxPct.U_1
xx% (default 95%) upper confidence bound of total above or below median estimate from the first survey
- Estimate.P_2
proportion above or below median estimate (in %) from the second survey
- StdError.P_2
standard error of proportion above or below median estimate from the second survey
- MarginofError.P_2
margin of error of proportion above or below median estimate from the second survey
- LCBxxPct.P_2
xx% (default 95%) lower confidence bound of proportion above or below median estimate from the second survey
- UCBxxPct.P_2
xx% (default 95%) upper confidence bound of proportion above or below median estimate from the second survey
- Estimate.U_2
total above or below median estimate from the second survey
- StdError.U_2
standard error of total above or below median estimate from the second survey
- MarginofError.U_2
margin of error of total above or below median estimate from the second survey
- LCBxxPct.U_2
xx% (default 95%) lower confidence bound of total above or below median estimate from the second survey
- UCBxxPct.U_2
xx% (default 95%) upper confidence bound of total above or below median estimate from the second survey
Author(s)
Tom Kincaid Kincaid.Tom@epa.gov
See Also
trend_analysis
for trend analysis
Examples
# Categorical variable example for three resource classes
dframe <- data.frame(
surveyID = rep(c("Survey 1", "Survey 2"), c(100, 100)),
siteID = paste0("Site", 1:200),
wgt = runif(200, 10, 100),
xcoord = runif(200),
ycoord = runif(200),
stratum = rep(rep(c("Stratum 1", "Stratum 2"), c(2, 2)), 50),
CatVar = rep(c("North", "South"), 100),
All_Sites = rep("All Sites", 200),
Resource_Class = sample(c("Good", "Fair", "Poor"), 200, replace = TRUE)
)
myvars <- c("CatVar")
mysubpops <- c("All_Sites", "Resource_Class")
change_analysis(dframe,
vars_cat = myvars, subpops = mysubpops,
surveyID = "surveyID", siteID = "siteID", weight = "wgt",
xcoord = "xcoord", ycoord = "ycoord", stratumID = "stratum"
)