【问题标题】:Kriging with gstat : "Covariance matrix singular at location" with predict带有 gstat 的克里金法:带有预测的“位置处的协方差矩阵奇异”
【发布时间】:2019-04-23 00:00:23
【问题描述】:

我正在尝试通过使用 gstat 进行克里金法进行估计,但由于协方差矩阵存在问题,我永远无法实现。我从来没有估计过我想要的位置,因为它们都被跳过了。对于每个位置,我都有以下警告消息:

1: In predict.gstat(g, newdata = newdata, block = block, nsim = nsim,  : 
Covariance matrix singular at location [-8.07794,48.0158,0]: skipping...

所有的估计都是不适用的。

到目前为止,我浏览了许多相关的 StackOverflow 线程,但没有一个能解决我的问题(https://gis.stackexchange.com/questions/222192/r-gstat-krige-covariance-matrix-singular-at-location-5-88-47-4-0-skippinghttps://gis.stackexchange.com/questions/200722/gstat-krige-error-covariance-matrix-singular-at-location-917300-3-6109e06-0https://gis.stackexchange.com/questions/262993/r-gstat-predict-error?rq=1

我检查过:

  • 我的数据集中实际上有一个空间结构(参见下面的气泡图和代码)

  • 没有重复的位置

  • 变异函数模型不是奇异的,并且与实验变异函数有很好的拟合(参见下面的代码图)

  • 我还尝试了 range、sill、nugget 的几个值以及 gstat 库中的所有模型

  • 协方差矩阵是正定的并且具有正的特征值。根据 gstat 是单数,而不是 is.singular.matrix 函数

  • 有足够的点对来做实验变异函数

如何克服这个问题?有什么技巧可以避免奇异协方差矩阵?我也欢迎任何克里金法的“最佳实践”。

代码(SO.Rdata 需要:https://www.dropbox.com/s/5vfj2gw9rkt365r/forSO.Rdata?dl=0):

library(ggplot2)
library(gstat)

#Attached Rdata
load("forSO.Rdata")

#The observations
str(abun)

#Spatial structure
abun %>% as.data.frame %>% 
  ggplot(aes(lon, lat)) +
  geom_point(aes(colour=prop_species_cells), alpha=3/4) + 
  coord_equal() + theme_bw()

#Number of pair of points
cvgm <- variogram(prop_species_cells ~1, data=abun, width=3,  cutoff=300)
plot(cvgm$dist,cvgm$np)

#Fit a model covariogram
efitted = fit.variogram(cvgm, vgm(model="Mat", range=100, nugget=1), fit.method=7, fit.sills=TRUE, fit.ranges=TRUE)
plot(cvgm,efitted)

#No warning, and the model is non singular
attr(efitted, "singular")

#Covariance matrix (only on a small set of points, I have more than 25000 points) : positive-definite, postiive eigen values and not singular
hex_pointsDegTiny=hex_pointsDeg
hex_pointsDegTiny@coords=hex_pointsDegTiny@coords[1:10,]
dists <- spDists(hex_pointsDegTiny)
covarianceMatrix=variogramLine(efitted, maxdist = max(cvgm$dist), n = 10*max(cvgm$dist), dir = c(1,0,0), dist_vector = dists, covariance = TRUE)
eigen(covarianceMatrix)$values
is.positive.definite(covarianceMatrix)
is.singular.matrix(covarianceMatrix)

# No duplicate locations
zerodist(hex_pointsDegTiny)

# Impossible to krig
OK_fit <- gstat(id = "OK_fit", formula = prop_species_cells ~ 1, data = abun, model = efitted)
dist <- predict(OK_fit, newdata = hex_pointsDegTiny)
dist@data

【问题讨论】:

    标签: r kriging gstat


    【解决方案1】:

    实际上,abun 数据集 (zerodist(abun)) 中有重复的位置,它们不会被搜索到我想要进行克里格估计的网格中。去除重复后,克里金法工作正常。

    【讨论】:

      猜你喜欢
      • 2020-09-01
      • 1970-01-01
      • 2020-09-01
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 2018-02-21
      • 2016-05-18
      • 2012-09-26
      相关资源
      最近更新 更多