Learn R Programming

spsurvey (version 1.6.2)

cat.analysis: Categorical Data Analysis for Probability Survey Data

Description

This function organizes input and output for analysis of categorical data generated by a probability survey. Input can be either an object belonging to class psurvey.analysis (see the documentation for function psurvey.analysis) or through use of the other arguments to this function.

Usage

cat.analysis(sites=NULL, subpop=NULL, design=NULL, data.cat=NULL,
   N.cluster=NULL, popsize=NULL, stage1size=NULL, popcorrect=FALSE,
   sizeweight=FALSE, unitsize=NULL, vartype="Local", conf=95, psurvey.obj=NULL)

Arguments

sites
a data frame consisting of two variables: the first variable is site IDs, and the second variable is a logical vector indicating which sites to use in the analysis. If psurvey.obj is not provided, then this argument is required. The defa
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. If psurvey.obj is not provided, then this argument is required. The default is NULL. Variables should be named as follows: siteID = site IDs wgt = final adjusted weights, which are either the weight
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. If psurvey.obj is not provided, then this argument is required. The default is N
N.cluster
the number of stage one sampling units in the resource, 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 containing a
popsize
the known size of the resource - the total number of sampling units of a finite resource or the measure of an extensive resource, which is used to adjust estimators for the known size of a resource. This argument also is required for calcu
stage1size
the known size of the stage one sampling units of a two-stage sample, 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
popcorrect
a logical value that indicates whether finite or continuous population correction factors should be employed during variance estimation, where TRUE = use the correction factors and FALSE = do not use the correction factors. The default
sizeweight
a logical value that indicates whether size-weights should be used in the analysis, where TRUE = use the size-weights and FALSE = do not use the size-weights. The default is FALSE.
unitsize
the known sum of the size-weights of the resource. The argument must be in the form of a list containing an element for each population Type in the subpop data frame, where NULL is a valid choice for a population Type. The list must
vartype
the choice of variance estimator, where "Local" = local mean estimator and "SRS" = SRS estimator. The default is "Local".
conf
the confidence level. The default is 95%.
psurvey.obj
a list of class psurvey.analysis that was produced by the function psurvey.analysis. Depending on input to that function, some elements of the list may be NULL. The default is NULL.

Value

  • Value is a data frame of population estimates for all combinations of subpopulation Types, subpopulations within Types, response variables, and categories within each response variable. Estimates are calculated for proportion and size of the population. Standard error estimates and confidence interval estimates also are calculated.

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

category.est

Examples

Run this code
# Categorical variable example for two resource classes
mysiteID <- paste("Site", 1:100, sep="")
mysites <- data.frame(siteID=mysiteID, Active=rep(TRUE, 100))
mysubpop <- data.frame(siteID=mysiteID, All.Sites=rep("All Sites", 100),
   Resource.Class=rep(c("Good","Poor"), c(55,45)))
mydesign <- data.frame(siteID=mysiteID, wgt=runif(100, 10, 100),
   xcoord=runif(100), ycoord=runif(100), stratum=rep(c("Stratum1",
   "Stratum2"), 50))
mydata.cat <- data.frame(siteID=mysiteID, CatVar=rep(c("north", "south",
   "east", "west"), 25))
mypopsize <- list(All.Sites=c(Stratum1=3500, Stratum2=2000),
   Resource.Class=list(Good=c(Stratum1=2500, Stratum2=1500),
   Poor=c(Stratum1=1000, Stratum2=500)))
cat.analysis(sites=mysites, subpop=mysubpop, design=mydesign,
   data.cat=mydata.cat, popsize=mypopsize)

# Exclude category "south" from the analysis
mysites <- data.frame(siteID=mysiteID, Active=rep(c(TRUE, FALSE, TRUE,
   TRUE), 25))
cat.analysis(sites=mysites, subpop=mysubpop, design=mydesign,
   data.cat=mydata.cat, popsize=mypopsize)

Run the code above in your browser using DataLab