首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用gstat进行克里格:“位置上的协方差矩阵奇异”和预测

用gstat进行克里格:“位置上的协方差矩阵奇异”和预测
EN

Stack Overflow用户
提问于 2018-11-20 14:03:53
回答 1查看 1.3K关注 0票数 1

我试图用gstat做一个估计,但由于协方差矩阵的问题,它永远无法实现。我从来没有估计过我想要的地点,因为它们都被跳过了。对于每个位置,我有以下警告信息:

代码语言:javascript
复制
1: In predict.gstat(g, newdata = newdata, block = block, nsim = nsim,  : 
Covariance matrix singular at location [-8.07794,48.0158,0]: skipping...

所有的估计都是NA。

到目前为止,我已经浏览了许多相关的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)

我查过了:

  • 实际上,我的数据集中有一个空间结构(参见下面代码的气泡图)。
  • 没有重复的地点
  • 变异函数模型不是奇异的,与实验的变异函数很好地吻合(见下面的代码图)。
  • 我还尝试了gstat库中的range、sill、nugget和所有模型的几个值。
  • 协方差矩阵是正定的,具有正的本征值。根据gstat,它是单数的,但对于is.singular.matrix函数则不是单数。
  • 有足够的点来做实验的变异函数

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

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

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-23 11:21:49

实际上,abun dataset (zerodist(abun))中有重复的位置,它们不会被搜索到我想要计算的网格中。去掉复印机后,克里金工作得很好。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53394748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档