[R-sig-Geo] GRTS sampling

Dick Brus dick.brus at wur.nl
Mon Feb 11 15:45:29 CET 2013


I try to understand the hierarchical randomization as applied in the GRTS
design.
   
I randomized 16 points on a square grid, see R script below. The argument
do.sample was set to FALSE, so that the result consists of a dataframe of
all 16 points instead of a GRTS sample. When plotting the order of the
points it appears that the numbers 1-4 are not always in different
subsquares (of which there are four) , for instance points 1 and 3 are both
in the lower-right subsquare. What am I doing wrong?
 
library(spsurvey)

frame<-expand.grid(x=seq(from=1,to=4,by=1),y=seq(from=1,to=4,by=1))

#population size (total number of sampling units in Kandahar)
N<-nrow(frame)

#set number of sampling units (sample size) to be selected
n<-4

design<-list(None=list(panel=c(Panel1=n), seltype="Equal", caty.n=c("Caty
1"=n), over=0))
x<-frame$x
y<-frame$y
index<-1:N
att<-data.frame(x=x,y=y,ids=index)

#do.sample=FALSE gives all sampling units in hierarchical? randomized order
res<-grts(design, DesignID="Site", SiteBegin=1, type.frame="finite",
         src.frame="att.frame", in.shape=NULL, sp.object=NULL,
att.frame=att,
         id=NULL, xcoord="x", ycoord="y", stratum=NULL, mdcaty=NULL,
startlev=2,
         maxlev=11, maxtry=1000, shift.grid=FALSE, do.sample=rep(FALSE,
length(design)),
         shapefile=FALSE, prjfilename=NULL, out.shape="sample")
frame.randomized<-data.frame(res$xcoord,res$ycoord)
names(frame.randomized)<-c("x","y")
frame.randomized$id<-1:N

png(file = "GRTSRandomizedFrameSquare.png", width = 480, height = 480)
print(
  ggplot(data = frame.randomized) +
    geom_text(
      data = frame.randomized,
      mapping = aes(
        x = x,
        y = y,
        label = id
      ),
      size = 5
    ) +
    coord_equal()
)
dev.off()

<http://r-sig-geo.2731867.n2.nabble.com/file/n7582569/GRTSRandomizedFrameSquare.png> 



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/GRTS-sampling-tp7582569.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list