Agriculture Reference
In-Depth Information
The
survey
package was used to compute the design-based estimates and their
standard errors (see Lumley
2010
for a review of its features). In this simulated
example, we have assumed that the preliminary necessary operations on the data
have been successfully completed. These include data entry, coding, editing, and
prepare the cleaned data set for analysis.
For design-based estimation, the function
svydesign
collects all the neces-
sary information for the sampling scheme (i.e., sampling-design identifiers, stratum
identification variables, cluster identification variables) and the sampling weights or
finite population corrections (i.e., the sampling rates) that are required for sampling
without replacement. Undoubtedly, a full awareness of the complexities of the
actual sampling design is required. The function
svytotal
estimates the popu-
lation totals, and its output includes the point estimates and their estimated standard
errors, the coefficients of variation, and the design effects (but obviously not for an
SRS design). These statistics are calculated using the information recorded in the
design object. Note that the package also includes different functions to estimate
other univariate population parameters such as
svymean
to estimate the mean,
svyquantile
to estimate the quantiles of the survey variable, and
svychisq
to
estimate a contingency table from the survey data. A set of functions is also
provided for the proper analysis of survey data, which exploit all the necessary
in the list of variables to be estimated,
svytotal
automatically realizes that the
estimation objects are the absolute frequencies of each code of the variable. The
coef
and
SE
utility functions extract the point estimate vectors and their standard
errors from the
svytotal
output. We can use the
interaction
function to
produce a cross tabulation of two qualitative variables, which creates all combina-
tions of the two sets of codes (the symbol
...
indicates that some redundant output is
dropped).
>
dsrs
<
- svydesign(id
¼
~1,data
¼
framesrs,fpc
¼
~rep(n/N,n))
>
esrs
<
- svytotal(~yobs+as.factor(q1obs),dsrs)
>
esrs
total
SE
yobs
91667 2111.419
as.factor(q1obs)1
270
42.330
as.factor(q1obs)2
350
45.477
as.factor(q1obs)3
380
46.280
>
coef(esrs)
...
>
SE(esrs)
...
>
qesrs
<
-svytotal(~interaction(q1obs,q2obs), design
¼
dsrs)
>
ftable(qesrs, rownames
¼
list(q1obs
¼
c("1","2","3"),
+
q2obs
¼
c("1","2","3","4","5")))
Search WWH ::
Custom Search