Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/spatialGaussianCopula.R
This function allows to do spatial prediction using a Gaussian Copula based on the spatial parametrization.
1 | spGaussCopPredict(corFun, predNeigh, dataLocs, predLocs, margin, p = 0.5, ..., n = 1000)
|
corFun |
A valid correlogram (i.e. producing a valid correlation matrix; e.g. based on a variogram). |
predNeigh |
A |
dataLocs |
a spatial object providing the data |
predLocs |
a spatial object providing the prediction locations |
margin |
a list containing the marginal distribution. Currently only the entry |
p |
the fraction the quantile function shall be evaluated for. This can be used to calculate besides the median estimate confidence estimates as well. |
... |
currently unused |
n |
the approximate number of points used in the linear approximation of the conditional distribution function. |
Based on corFun
provided with a distance matrix a Gaussian copula (normalCopula
) is generated and conditioned under the data of the neighbouring locations. The 1-dimensional conditional distribution is approximated and evaluated for the given fraction p
. This conditioned fraction is than passed on to the marginal quantile function and evaluated providing an estimate.
According to the predLocs
slot of the provided neighbourhood
a spatial data structure extended with an variable holding the predicted values.
Benedikt Graeler
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 | # load data from the Meuse demo
data("spCopDemo")
# calculate the correlation function based on Kendall's tau
calcKTauPol <- fitCorFun(bins, degree=1)
# translate Kendall's tau correlation function into Gaussian Copula parameters
# using a linear variogram
meuseGaussCorFun <- function(h) {
res <- pmax(iTau(normalCopula(0), calcKTauPol(0))/658*(658-h),0)
res[h ==0] <- 1
return(res)
}
# get some prediction data
library("sp")
data("meuse.grid")
coordinates(meuse.grid) <- ~x+y
gridded(meuse.grid) <- TRUE
data("meuse")
coordinates(meuse) <- ~x+y
meuse$rtZinc <- rank(meuse$zinc)/(length(meuse)+1)
# obtain the prediction neighbourhoods
predMeuseNeigh <- getNeighbours(meuse[1:4,], meuse.grid[c(9:12,16:19,25:28),],
5, "rtZinc", prediction=TRUE, min.dist=-1)
qMar <- function(x) {
qlnorm(x,mean(log(meuse$zinc)),sd(log(meuse$zinc)))
}
# predict using the Gaussian Copula
predMedian <- spGaussCopPredict(meuseGaussCorFun, predMeuseNeigh,
meuse[1:4,], meuse.grid[c(9:12,16:19,25:28),],
list(q=qMar))
## Not run:
spplot(predMedian,"quantile.0.5",
sp.layout=list("sp.points", meuse, pch = 19, col = "red"),
col.regions=bpy.colors())
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.