Learn R Programming

spatialEco (version 0.1-5)

mwCorr: Dutilleul moving window bivariate raster correlation

Description

A bivarate raster corrlation using Dutilleul's modified t-test

Usage

mwCorr(x, y, x.idx = 1, y.idx = 1, d = "AUTO", sub.sample = FALSE, type = "hexagon", p = 0.1, size = NULL)

Arguments

x
x raster for correlation, SpatialPixelsDataFrame or SpatialGridDataFrame object
y
y raster for correlation, SpatialPixelsDataFrame or SpatialGridDataFrame object
x.idx
Index for the column in the x raster object
y.idx
Index for the column in the y raster object
d
Distance for finding neighbors
sub.sample
Should a subsampling approach be employed (TRUE/FALSE)
type
If sub.sample = TRUE, what type of sample (random or hexagon)
p
If sub.sample = TRUE, what proportion of population should be sampled
size
Fixed sample size

Value

A SpatialPixelsDataFrame or SpatialPointsDataFrame with the following attributes:
  • corr Correlation
  • Fstat The F-statistic
  • p.value p-value for the test
  • moran.x Moran's-I for x
  • moran.y Moran's-I for y

References

Clifford, P., S. Richardson, D. Hemon (1989), Assessing the significance of the correlation between two spatial processes. Biometrics 45:123-134. Dutilleul, P. (1993), Modifying the t test for assessing the correlation between two spatial processes. Biometrics 49:305-314.

Examples

Run this code
## Not run: 
# library(gstat)                                         
# library(sp)                                            
#                                                         
# data(meuse)                                            
# data(meuse.grid)                                       
# coordinates(meuse) <- ~x + y                           
# coordinates(meuse.grid) <- ~x + y                      
#                                                         
# # GRID-1 log(copper):                                              
# v1 <- variogram(log(copper) ~ 1, meuse)                  
# x1 <- fit.variogram(v1, vgm(1, "Sph", 800, 1))           
# G1 <- krige(zinc ~ 1, meuse, meuse.grid, x1, nmax = 30)
# gridded(G1) <- TRUE                                      
# G1@data = as.data.frame(G1@data[,-2])
# 
# # GRID-2 log(elev):                                              
# v2 <- variogram(log(elev) ~ 1, meuse)                  
# x2 <- fit.variogram(v2, vgm(.1, "Sph", 1000, .6))        
# G2 <- krige(elev ~ 1, meuse, meuse.grid, x2, nmax = 30)
# gridded(G2) <- TRUE    
# G2@data <- as.data.frame(G2@data[,-2])
# G2@data[,1] <- G2@data[,1]
# 
# corr <- mwCorr(G1, G2)	  
# corr.hex <- mwCorr(G1, G2, sub.sample = TRUE)	
# corr.rand <- mwCorr(G1, G2, sub.sample = TRUE, type = "random")	
# 
# corr.hex <- mwCorr(G1, G2, sub.sample = TRUE, d = 500, size = 1000)	
#   head(corr.hex@data)
#   bubble(corr.hex, "corr")
# ## End(Not run)

Run the code above in your browser using DataLab