Agriculture Reference
In-Depth Information
Fig. 7.1 Random mapping of a spatial set of points in one dimension with equal ( left ), and
unequal ( right ) inclusion probabilities (size of the point and length of the segment)
The spsurvey package was specifically developed to select samples using the
GRTS method. The reference manual for spsurvey can be downloaded at http://
cran.r-project.org/web/packages/spsurvey/spsurvey.pdf . The example below is
based on the artificial data set that was introduced in Chap. 6 . The only remarkable
difference is in the generation of the variable ypps.
> library(sampling)
> library(survey)
> 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
> ypps < - exp(yobs/10)
> q1obs < - sample(1:3,N,replace ¼ T)
> framepop < - cbind(framepop,yobs,ypps,q1obs)
We also present a simple code that uses a wrapper function GRTS to select
random samples from a finite list of points. We have used the tripack package to
calculate the boundaries, and to overlay the Voronoi polygons on the selected
sample. Note that the circled points in the plot are the selected sample (see Fig. 7.2 ).
> library(spsurvey)
> n < - 100
Search WWH ::




Custom Search