Learn R Programming

spsurvey (version 2.6)

change.analysis: Change Analysis for Probability Survey Data

Description

This function organizes input and output for analysis of change between two probability surveys.

Usage

change.analysis(sites, repeats=NULL, subpop=NULL, design, data.cat=NULL,
   data.cont=NULL, revisitwgt=FALSE, popsize_1=NULL, popsize_2=NULL,
   popcorrect_1=FALSE, popcorrect_2=FALSE, pcfsize_1=NULL, pcfsize_2=NULL,
   N.cluster_1=NULL, N.cluster_2=NULL, stage1size_1=NULL, stage1size_2=NULL,
   sizeweight_1=FALSE, sizeweight_2=FALSE, vartype_1="Local", vartype_2="Local",
   conf=95)

Arguments

sites
a data frame consisting of three variables: the first variable is site IDs, and the other variables are logical vectors indicating which sites to use in the analysis. The first logical vector indicates the complete set of sites for the fir
repeats
a data frame that identifies site IDs for repeat visit sites from the two surveys. The first variable is site IDs for survey one. The second variable is site IDs for survey two. For each row of the data frame, the two site IDs must correspo
subpop
a data frame describing sets of populations and subpopulations for which estimates will be calculated. The first variable is site IDs. Each subsequent variable identifies a Type of population, where the variable name is used to identif
design
a data frame consisting of design variables. Variables should be named as follows: siteID = site IDs wgt = final adjusted weights, which are either the weights for a single-stage sample or the stage two weights for a two-stage sample xcoord
data.cat
a data frame of categorical response variables. The first variable is site IDs. Subsequent variables are response variables. Missing data (NA) is allowed. The default is NULL.
data.cont
a data frame of continuous response variables. The first variable is site IDs. Subsequent variables are response variables. Missing data (NA) is allowed. The default is NULL.
revisitwgt
a logical value that indicates whether the repeat visit sites in the two surveys have the same survey design weights, where TRUE = the weights are the same and FALSE = the weights are not the same. When this argument is FALSE, the repeat v
popsize_1
known size of the resource for survey one, which is used to perform ratio adjustment to estimators expressed using measurement units for the resource and to calculate strata proportions for calculating estimates for a stratified sample. Fo
popsize_2
known size of the resource for survey two. The default is NULL.
popcorrect_1
a logical value that indicates whether finite or continuous population correction factors should be employed during variance estimation for survey one, where TRUE = use the correction factors and FALSE = do not use the correction factors.
popcorrect_2
a logical value that indicates whether finite or continuous population correction factors should be employed during variance estimation for survey two. The default is FALSE.
pcfsize_1
size of the resource for survey one, which is required for calculation of finite and continuous population correction factors for a single-stage sample. For a stratified sample this argument must be a vector containing a value for each str
pcfsize_2
size of the resource for survey two. The default is NULL.
N.cluster_1
the number of stage one sampling units in the resource for survey one, which is required for calculation of finite and continuous population correction factors for a two-stage sample. For a stratified sample this variable must be a vector
N.cluster_2
the number of stage one sampling units in the resource for survey two. The default is NULL.
stage1size_1
size of the stage one sampling units of a two-stage sample for survey one, which is required for calculation of finite and continuous population correction factors for a two-stage sample and must have the names attribute set to identify the
stage1size_2
size of the stage one sampling units of a two-stage sample for survey two. The default is NULL.
sizeweight_1
a logical value that indicates whether size-weights should be used in the analysis of survey one, where TRUE = use the size-weights and FALSE = do not use the size-weights. The default is FALSE.
sizeweight_2
a logical value that indicates whether size-weights should be used in the analysis of survey two. The default is FALSE.
vartype_1
the choice of variance estimator for survey one, where "Local" = local mean estimator and "SRS" = SRS estimator. The default is "Local".
vartype_2
the choice of variance estimator for survey two. The default is "Local".
conf
the confidence level. The default is 95%.

Value

  • Value is a data frame of change estimates for all combinations of population Types, subpopulations within Types, response variables, and categories within each response variable (for categorical variables only). Estimates provided plus standard error and confidence interval estimates.

References

Diaz-Ramos, S., D.L. Stevens, Jr., and A.R. Olsen. (1996). EMAP Statistical Methods Manual. EPA/620/R-96/XXX. Corvallis, OR: U.S. Environmental Protection Agency, Office of Research and Development, National Health Effects and Environmental Research Laboratory, Western Ecology Division.

See Also

change.est

Examples

Run this code
# Categorical variable example for three resource classes:
mysiteID <- paste("Site", 1:200, sep="")
mysites <- data.frame(siteID=mysiteID,
                      Survey1=rep(c(TRUE, FALSE), c(100,100)),
                      Survey2=rep(c(FALSE, TRUE), c(100,100)))
myrepeats <- data.frame(siteID_1=paste("Site", 1:40, sep=""),
                        siteID_2=paste("Site", 101:140, sep=""))
mysubpop <- data.frame(siteID=mysiteID,
                       All_Sites=rep("All Sites", 200),
                       Region=rep(c("North","South"), 100))
mydesign <- data.frame(siteID=mysiteID,
                       wgt=runif(200, 10, 100),
                       xcoord=runif(200),
                       ycoord=runif(200),
                       stratum=rep(rep(c("Stratum1", "Stratum2"), c(2,2)), 50))
mydata.cat <- data.frame(siteID=mysiteID,
                         Resource_Class=sample(c("Good","Fair","Poor"),
                            200, replace=TRUE))
change.analysis(sites=mysites, repeats=myrepeats, subpop=mysubpop,
   design=mydesign, data.cat=mydata.cat, data.cont=NULL)

Run the code above in your browser using DataLab