Learn R Programming

GriegSmith (version 1.0)

GriegSmith: 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

Value

    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

    Run this code
    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;
    
    	
    
    
      }

    Run the code above in your browser using DataLab