Last data update: 2014.03.03

R: Grieg-Smith Calculation
GriegSmithR Documentation

Grieg-Smith Calculation

Description

This function accepts a point process object, a two column matrix of x-y coordinate pairs or a three column matrix containing x-y coordinates and quadrat counts in the third column. If the data contains quadrat counts, then the counts=TRUE option must be selected. The function returns a GriegSmith object which is a matrix with block sizes, sum of squares for each block size as well as mean sums of squares. Simulation envelopes are produced as well through randombly permuting the quadrat counts. The 5th and 95th percentiles of the permutations create the simulation envelope.

Ploting the GriegSmith object produces a plot of the MSr as well as the simulation envelopes.

Usage

GriegSmith(datapoints, counts = FALSE, env = 100)
## S3 method for class 'GriegSmith'
plot(x,main, ...)

Arguments

datapoints

datapoints is either a point process object (ppp), a two column matrix of x-y coordinates, or a three column matrix of x-y quadrat coords with a third column of quadrat counts.

counts

If datapoints is a three column matrix with quadrat counts, then set counts=T

env

How many permuatations should be used to create the simulation envelopes default=100.

x

A GriegSmith object created with GriegSmith()

main

the graph title

...

other parameters passed to the plot function

Author(s)

Brian McGuire

References

Statistical Methods for Spatial Data Analysis. Oliver Schabenberger and Carol A. Gotway . Boca Raton, FL: Chapman & Hall/CRC, 2005.

Greig-Smith, P. 1952. The use of random and contiguous quadrats in the study of structure in plant communities. Annals of Botany 16:293-316.

Examples


data(amacrine,package="spatstat")
GS_ama<-GriegSmith(amacrine);
plot(GS_ama)




## The function is currently defined as
function(datapoints,counts=FALSE,env=100){


	if(counts==FALSE){

	if(is.ppp(datapoints)){

		xmin<-datapoints$window$xrange[1]
		xmax<-datapoints$window$xrange[2]

		ymin<-datapoints$window$yrange[1]
		ymax<-datapoints$window$yrange[2]


		datapoints<-cbind(datapoints$x,datapoints$y);


		
	}
	else{

		xmax<-max(datapoints[,1]);
		xmin<-min(datapoints[,1]);

		ymax<-max(datapoints[,2]);
		ymin<-min(datapoints[,2]);





	}


		
	
	numpts<-length(datapoints[,1]);
	startingdim<-ceiling(log(numpts)/(2*log(2)));
	counts<-sums(datapoints,2^startingdim,xmin,xmax,ymin,ymax)
		

	}
	else {
		if (max(datapoints[,1]) != max(datapoints[,2])) stop("Your count data must have equal dimensions")


		datapoints<-datapoints[order(datapoints[,2],datapoints[,1]),]
		numpts<-sum(datapoints[,3])
		startingdim<-ceiling(log(max(datapoints[,1]))/log(2))
		counts<-matrix(datapoints[,3],nrow=2^startingdim,byrow=TRUE);
	
		
	}	


	actual<-iterate(counts,startingdim);
	sims<-envelopes(env,counts,startingdim);
	final<-cbind(actual,sims);
	

	colnames(final)<-c("blocksize","SSr","MSr","MSr.05","MSr.95");

	
	class(final) <- "GriegSmith"


	final;

	


  }

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GriegSmith)
Loading required package: spatstat
Loading required package: nlme
Loading required package: rpart

spatstat 1.45-2       (nickname: 'Caretaker Mode') 
For an introduction to spatstat, type 'beginner' 

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GriegSmith/GriegSmith.Rd_%03d_medium.png", width=480, height=480)
> ### Name: GriegSmith
> ### Title: Grieg-Smith Calculation
> ### Aliases: GriegSmith plot.GriegSmith
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> 
> data(amacrine,package="spatstat")
> GS_ama<-GriegSmith(amacrine);
> plot(GS_ama)
> 
> 
> 
> 
> ## The function is currently defined as
> function(datapoints,counts=FALSE,env=100){
+ 
+ 
+ 	if(counts==FALSE){
+ 
+ 	if(is.ppp(datapoints)){
+ 
+ 		xmin<-datapoints$window$xrange[1]
+ 		xmax<-datapoints$window$xrange[2]
+ 
+ 		ymin<-datapoints$window$yrange[1]
+ 		ymax<-datapoints$window$yrange[2]
+ 
+ 
+ 		datapoints<-cbind(datapoints$x,datapoints$y);
+ 
+ 
+ 		
+ 	}
+ 	else{
+ 
+ 		xmax<-max(datapoints[,1]);
+ 		xmin<-min(datapoints[,1]);
+ 
+ 		ymax<-max(datapoints[,2]);
+ 		ymin<-min(datapoints[,2]);
+ 
+ 
+ 
+ 
+ 
+ 	}
+ 
+ 
+ 		
+ 	
+ 	numpts<-length(datapoints[,1]);
+ 	startingdim<-ceiling(log(numpts)/(2*log(2)));
+ 	counts<-sums(datapoints,2^startingdim,xmin,xmax,ymin,ymax)
+ 		
+ 
+ 	}
+ 	else {
+ 		if (max(datapoints[,1]) != max(datapoints[,2])) stop("Your count data must have equal dimensions")
+ 
+ 
+ 		datapoints<-datapoints[order(datapoints[,2],datapoints[,1]),]
+ 		numpts<-sum(datapoints[,3])
+ 		startingdim<-ceiling(log(max(datapoints[,1]))/log(2))
+ 		counts<-matrix(datapoints[,3],nrow=2^startingdim,byrow=TRUE);
+ 	
+ 		
+ 	}	
+ 
+ 
+ 	actual<-iterate(counts,startingdim);
+ 	sims<-envelopes(env,counts,startingdim);
+ 	final<-cbind(actual,sims);
+ 	
+ 
+ 	colnames(final)<-c("blocksize","SSr","MSr","MSr.05","MSr.95");
+ 
+ 	
+ 	class(final) <- "GriegSmith"
+ 
+ 
+ 	final;
+ 
+ 	
+ 
+ 
+   }
function (datapoints, counts = FALSE, env = 100) 
{
    if (counts == FALSE) {
        if (is.ppp(datapoints)) {
            xmin <- datapoints$window$xrange[1]
            xmax <- datapoints$window$xrange[2]
            ymin <- datapoints$window$yrange[1]
            ymax <- datapoints$window$yrange[2]
            datapoints <- cbind(datapoints$x, datapoints$y)
        }
        else {
            xmax <- max(datapoints[, 1])
            xmin <- min(datapoints[, 1])
            ymax <- max(datapoints[, 2])
            ymin <- min(datapoints[, 2])
        }
        numpts <- length(datapoints[, 1])
        startingdim <- ceiling(log(numpts)/(2 * log(2)))
        counts <- sums(datapoints, 2^startingdim, xmin, xmax, 
            ymin, ymax)
    }
    else {
        if (max(datapoints[, 1]) != max(datapoints[, 2])) 
            stop("Your count data must have equal dimensions")
        datapoints <- datapoints[order(datapoints[, 2], datapoints[, 
            1]), ]
        numpts <- sum(datapoints[, 3])
        startingdim <- ceiling(log(max(datapoints[, 1]))/log(2))
        counts <- matrix(datapoints[, 3], nrow = 2^startingdim, 
            byrow = TRUE)
    }
    actual <- iterate(counts, startingdim)
    sims <- envelopes(env, counts, startingdim)
    final <- cbind(actual, sims)
    colnames(final) <- c("blocksize", "SSr", "MSr", "MSr.05", 
        "MSr.95")
    class(final) <- "GriegSmith"
    final
}
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>