Dick--
I can't explain exactly why, but having your design draw all 16 points is a
problem, even though one might expect that do.sample=FALSE would ignore the
panel size.

frame<-expand.grid(x=seq(from=1,to=4,by=1),y=seq(from=1,to=4,by=1))
design.2 <- list(None=list(panel=c(P1=4),seltype="Equal"))

res.2 <- grts(design=design.2,
                   type.frame="finite",
                   src.frame="att.frame",
                   att.frame=frame,
                   xcoord="x",ycoord="y",
                   mdcaty="ID",
                   shift.grid=FALSE,
                   do.sample=FALSE)
res.2$quadrant <- (res.2$x>=3) + (res.2$y>=3) * 2
res.2

Tom 2


On Mon, Feb 11, 2013 at 6:45 AM, Dick Brus <dick.brus@wur.nl> wrote:

> 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.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

