Learn R Programming

spsurvey (version 4.1.4)

framesum: Summary of the Sample Frame for a Survey Design

Description

This function summarizes the frame for a survey design. When type.frame equals "finite", summary is a count of number of units in att.frame for cross-tabulation of stratum, mdcaty, and auxvar. When type.frame equals "linear" or "area", summary is the sum of length or area for units for cross- tabulation of stratum, mdcaty, and auxvar. If argument mdcaty or argument stratum equals NULL or if both arguments equal NULL, then the cross-tabulation is performed without use of the design variable(s).

Usage

framesum(att.frame, design, type.frame = "finite", stratum = NULL,
  mdcaty = NULL, auxvar = NULL, units.in = "Number", scale = 1,
  units.out = "Number")

Arguments

att.frame

Data frame composed of attributes associated with elements in the frame, which must contain the columns used for stratum and mdcaty (if required by the survey design).

design

Named list of stratum design specifications which are also lists. Stratum names must be subset of values in stratum argument. Each stratum list has four components:

panel

named vector of sample sizes for each panel in stratum

seltype

the type of random selection, which must be one of following: "Equal" - equal probability selection, "Unequal" - unequal probability selection by the categories specified in caty.n and mdcaty, or "Continuous" - unequal probability selection proportional to auxiliary variable mdcaty

caty.n

if seltype equals "Unequal", a named vector of sample sizes for each category specified by mdcaty, where sum of the sample sizes must equal sum of the panel sample sizes, and names must be a subset of values in mdcaty

over

number of replacement sites ("oversample" sites) for the entire design, which is set equal to 0 if none are required)

Example design: design=list( Stratum1=list(panel=c(PanelOne=50), seltype="Equal", over=10), Stratum2=list(panel=c(PanelOne=50, PanelTwo=50), seltype="Unequal", caty.n=c(CatyOne=25, CatyTwo=25, CatyThree=25, CatyFour=25), over=75))

type.frame

The type of frame, which must be one of following: "finite", "linear", or "area". The default is "finite".

stratum

Name of the column from att.frame that identifies stratum membership for each element in the frame. If stratum equals NULL, the design is unstratified. The default is NULL.

mdcaty

Name of the column from att.frame that identifies the unequal probability category for each element in the frame. The default is NULL.

auxvar

Vector containing the names of columns from att.frame that identify auxiliary variables to be used to summarize frame size. The default is NULL.

units.in

Character string giving the name of units used to measure size in the frame. The default is "Number".

scale

The scale factor used to change units.in to units.out. For example, use 1000 to change "Meters" to "Kilometers". The default is 1.

units.out

Character string giving the name of units used to measure size in the results. The default is "Number".

Value

A list containing two components named DesignSize and AuxVarSize. DesignSize summarizes the frame for survey design variables, and AuxVarSize summarizes the frame for auxiliary variables. DesignSize is either a table (for type.frame equals "finite") or an array (for type.frame equals "linear" or "area") that contains the cross-tabulation of frame extent for design variables multidensity category (mdcaty) and stratum, where extent of the frame is the number of sites for type.frame equals "finite", the sum of resource length for type.frame equals "linear", or the sum of resource area for type.frame equals "area". AuxVarSize is a list containing a component for each auxiliary variable, where each component of the list is one of the following: (1) if the type of random selection does not equal "Continuous" for any stratum, each component is either a table (for type.frame equals "finite") or an array (for type.frame equals "linear" or "area") that contains the cross-tabulation of frame extent for mdcaty, stratum, and the auxiliary variable or (2) if type of random selection equals "Continuous" for all strata, each component is either a table (finite frame) or an array (linear or area frame) containing the cross-tabulation of frame extent for stratum and the auxiliary variable. In addition the output list plus labeling information is printed to the console.

Other Functions Required

vecprint

takes an input vector and outputs a character string with line breaks inserted

Examples

Run this code
# NOT RUN {
attframe <- read.dbf("shapefile.shp")
design <- list(
  Stratum1=list(panel=c(PanelOne=50), seltype="Equal", over=10),
  Stratum2=list(panel=c(PanelOne=50, PanelTwo=50), seltype="Unequal",
    caty.n=c(CatyOne=25, CatyTwo=25, CatyThree=25, CatyFour=25), over=75))
framesum(att.frame=attframe, design=design, type.frame="area",
  stratum="stratum", mdcaty="mdcaty", auxvar=c("ecoregion",
  "state"), units.in="Meters", scale=1000, units.out="Kilometers")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab