Agriculture Reference
In-Depth Information
sample observations available for the d- th SA, the HT direct estimator is unbiased
with respect to the design, but not efficient. In SAE problems that have an
inadequate sample size, this estimator can be biased and unreliable. Furthermore,
it is characterized by a very high variance. As a consequence, the previous estima-
tors are not typically used in practical applications.
We can compute the direct estimates with R , using the survey and sae
( ad-hoc ) packages. The reference manual for sae can be downloaded from
http://cran.r-project.org/web/packages/sae/sae.pdf . The following example is
based on the artificial data set that was introduced in Chap. 6 when describing
basic common sampling designs. This simple code generates the sample.
> library(sampling)
> library(survey)
> library(sae)
> n < - 100
> N < - 1000
> set.seed(160964)
> framepop < - data.frame(id ¼ 1:N, xc ¼ runif(N), yc ¼ runif(N))
> yobs < - (exp((framepop$xc-0.5)^2)+exp((framepop$yc-0.5)^2))
> yobs < -100- ((yobs -min(yobs))/ (max (yobs -min(yobs)))) *100+
+ (rnorm(N)+5)*5
> q1obs < - sample(1:3,N,replace¼T)
> q2obs < - as.numeric(cut(yobs,quantile(yobs,probs¼ seq(0, 1, 0.2))))
> q2obs[is.na(q2obs)] < -1
> coddom < -(floor(framepop$xc*3)+1)*10+(floor(framepop$yc*3)+1
> framepop < - cbind(framepop,yobs,q1obs,q2obs,coddom)
> srs < - srswor(n,N)
> framesrs < - framepop[srs ¼¼ 1,]
> dsrs < - svydesign(id ¼ ~1,data ¼ framesrs,fpc ¼ ~rep(n/N,n))
The population of units ( N ¼1,000) with geographical coordinates (xc,yc) is
generated from a uniform distribution (0,1). We then select an SRS ( n ¼100). The
instruction coddom creates a square 3 3 lattice grid that is superimposed on the
population of units. In this example, we define 9 SAs denoted as
(11,12,13,21,22,23,31,32,33), and each of the population units
belongs to one SA. Furthermore, a target variable (yobs) and two qualitative
variables (q1obs, q2obs) are generated. The line srs < -srswor(n,N)
selects a simple random sample from the population. Finally, dsrs-
< -svydesign (id¼~1, data¼ framesrs, fpc¼~rep(n/N,n))
defines the sampling design using the survey module.
The map of points (see Fig. 11.1 ) and created SAs can be plotted using the
following commands.
Search WWH ::




Custom Search