Description Usage Arguments Details Value References See Also Examples
This function performs the nonparametric test of isotropy using the sample semivariogram from Guan et. al. (2004) for spatial data with sampling locations on a grid. See Guan et. al. (2004) for more details.
1 2 3 4 |
spdata |
An n x 3 matrix. The first two columns provide (x,y) spatial coordinates. The third column provides data values at the coordinates. This argument can also be an object of class |
delta |
A scalar indicating the distance between grid locations. Defaults to 1 (integer grid) and assumes equal spacing between locations in the x and y directions. |
lagmat |
A k x 2 matrix of spatial lags. Each row corresponds to a lag of the form x.lag, y.lag for which the semivariogram value will be estimated. The scale of the lags provided in 'lagmat' are in units of |
A |
A d x k contrast matrix. The contrasts correspond to contrasts of the estimated semivariogram at the lags given in |
df |
A scalar indicating the row rank of the matrix |
window.dims |
A vector of length two corresponding to the width and height (in number of columns and rows, respectively) of the moving windows used to estimate the asymptotic variance-covariance matrix. If window width does not evenly divide the number of columns of spatial data, some data will be ommited during subsampling, i.e., function does not handle partial windows. Same applies to window height and number of rows of spatial data. |
pt.est.edge |
Logical. |
sig.est.edge |
Logical. Defaults to |
sig.est.finite |
Logical. Defaults to |
This function currently only supports square and rectangular sampling regions and does not currently support partial blocks. For example, suppose the sampling grid contains 20 columns and 30 rows of data. Then an ideal value of window.dims
would be (2,3) since its entries evenly divide the number of columns (20) and rows (30), respectively, of data. To preserve the spatial dependence structure, the moving window should have the same shape (i.e., square or rectangle) and orientation as the entire sampling domain.
The parameter delta
serves to scale the samplng locations to the integer grid. Thus the lags provided in lagmat
are automatically scaled by delta
by the function. For example, suppose spatial locations are observed on grid boxes of 0.5 degrees by 0.5 degrees and referenced by longitude and latitude coordinates in degrees. Then, delta
should be 0.5 and a spatial lag of (0,1) corresponds to a change in coordinates of (0, 0.5), i.e., moving one sampling location north in the y-direction.
gamma.hat |
A matrix of the spatial lags provided and the semivariogram point estimates,gamma-hat, at the lags used to construct the test statistic. |
sigma.hat |
The estimate of asymptotic variance-covariance matrix, Sigma-hat, used to construct the test statistic. |
n.subblocks |
The number of subblocks created by the moving window used to estimate Sigma. |
test.stat |
The calculated test statistic. |
pvalue.finite |
The approximate, finite-sample adjusted p-value computed by using the subblocks created by the moving windows (see Guan et. al. (2004), Section 3.3 for details). |
pvalue.chisq |
The p-value computed using the asymptotic Chi-squared distribution. |
Guan, Y., Sherman, M., & Calvin, J. A. (2004). A nonparametric test for spatial isotropy using subsampling. Journal of the American Statistical Association, 99(467), 810-821.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | library(mvtnorm)
set.seed(1)
#number of rows and columns
nr <- 12
nc <- 18
n <- nr*nc
#Set up the coordinates
coords <- expand.grid(0:(nr-1), 0:(nc-1))
coords <- cbind(coords[,2], coords[,1])
#compute the distance between sampling locations
D <- as.matrix(dist(coords))
#Set parameter values for exponential covariance function
sigma.sq <- 1
tau.sq <- 0.0
phi <- 1/4
R <- sigma.sq * exp(-phi*D)
R <- R + diag(tau.sq, nrow = n, ncol = n)
#Simulate Gaussian spatial data
z <- rmvnorm(1,rep(0,n), R, method = c("chol"))
z <- z-mean(z)
z <- t(z)
mydata <- cbind(coords, z)
mylags <- rbind(c(1,0), c(0, 1), c(1, 1), c(-1,1))
myA <- rbind(c(1, -1, 0 , 0), c(0, 0, 1, -1))
tr <- GuanTestGrid(mydata, delta = 1, mylags, myA, df = 2, window.dims = c(3,2),
pt.est.edge = TRUE, sig.est.edge = TRUE, sig.est.finite = TRUE )
tr
library(geoR)
#Simulate data from anisotropic covariance function
aniso.angle <- pi/4
aniso.ratio <- 2
coordsA <- coords.aniso(coords, c(aniso.angle, aniso.ratio))
Da <- as.matrix(dist(coordsA))
R <- sigma.sq * exp(-phi*Da)
R <- R + diag(tau.sq, nrow = n, ncol = n)
z <- rmvnorm(1,rep(0,n), R, method = c("chol"))
z <- z-mean(z)
z <- t(z)
mydata <- cbind(coords, z)
#Run the test on the data generated from an anisotropic covariance function
tr <- GuanTestGrid(mydata, delta = 1, mylags, myA, df = 2, window.dims = c(3,2),
pt.est.edge = TRUE,sig.est.edge = TRUE, sig.est.finite = TRUE)
tr
|
Warning message:
no DISPLAY variable so Tk is not available
Test of isotropy from Guan et. al. (2004) for gridded sampling
locations using the sample semivariogram.
data: mydata
Chi-sq = 2.9584, df = 2, p-value = 0.2278
p-value (finite adj.) = 0.2214, number of subblocks: 140
alternative hypothesis: true difference in directional semivariograms is not equal to 0
sample estimates: (lag value)
(1,0) (0,1) (1,1) (-1,1)
0.1969077 0.2242709 0.3032146 0.2561285
estimated asymp. variance-covariance matrix:
[,1] [,2] [,3] [,4]
[1,] 0.07504499 0.02660722 0.06308971 0.01260259
[2,] 0.02660722 0.11766502 0.09177491 0.05676432
[3,] 0.06308971 0.09177491 0.23528659 0.03314668
[4,] 0.01260259 0.05676432 0.03314668 0.13435719
--------------------------------------------------------------
Analysis of Geostatistical Data
For an Introduction to geoR go to http://www.leg.ufpr.br/geoR
geoR version 1.7-5.2.1 (built on 2016-05-02) is now loaded
--------------------------------------------------------------
Test of isotropy from Guan et. al. (2004) for gridded sampling
locations using the sample semivariogram.
data: mydata
Chi-sq = 6.4461, df = 2, p-value = 0.03983
p-value (finite adj.) = 0.07857, number of subblocks: 140
alternative hypothesis: true difference in directional semivariograms is not equal to 0
sample estimates: (lag value)
(1,0) (0,1) (1,1) (-1,1)
0.1501569 0.1620805 0.1605273 0.2308607
estimated asymp. variance-covariance matrix:
[,1] [,2] [,3] [,4]
[1,] 0.03270755 0.01535850 0.01499978 0.02653751
[2,] 0.01535850 0.05845650 0.03970033 0.06280898
[3,] 0.01499978 0.03970033 0.07477758 0.02832137
[4,] 0.02653751 0.06280898 0.02832137 0.15253332
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.