You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

含tessellation与标记交互的点过程模型无效原因咨询

问题:点过程模型拟合报错的原因分析

近日分析某空间域上的点级时空数据时,尝试拟合一个包含空间域tessellation与过程分类标记交互的点过程模型。使用ppm()函数时返回警告:Standard errors unavailable; variance-covariance matrix is singular. Model is not valid,且已通过模拟数据复现该问题,代码如下:

suppressPackageStartupMessages(library(spatstat))

set.seed(1)
X <- points <- rpoispp(50)
marks(X) <- sample(c("A", "B"), size = npoints(X), replace = TRUE) |> factor()
ts <- tess(xgrid = c(0, 0.5, 1), ygrid = c(0, 0.5, 1))

# ppm(X ~ 1) looks good
# ppm(X ~ ts) looks good
# ppm(X ~ marks) looks good
ppm(X ~ ts:marks)
#> Warning: Cannot compute variance; model is not valid
#> Nonstationary multitype Poisson process
#> Fitted to point pattern dataset 'X'
#> 
#> Possible marks: 'A' and 'B'
#> 
#> Log intensity:  ~ts:marks
#> 
#> Fitted trend coefficients:
#>                (Intercept) tsTile row 1, col 1:marksA 
#>               3.332205e+00              -3.364722e-01 
#> tsTile row 1, col 2:marksA tsTile row 2, col 1:marksA 
#>              -3.364722e-01              -3.364722e-01 
#> tsTile row 2, col 2:marksA tsTile row 1, col 1:marksB 
#>               1.335314e-01              -5.596158e-01 
#> tsTile row 1, col 2:marksB tsTile row 2, col 1:marksB 
#>              -5.596158e-01               4.994384e-13 
#> tsTile row 2, col 2:marksB 
#>                         NA 
#> 
#> Standard errors unavailable; variance-covariance matrix is singular
#> 
#> *** Model is not valid ***
#> *** Some coefficients are NA or Inf ***

Created on 2023-11-01 with reprex v2.0.2

原因分析与解决方案

核心原因

  • 完全共线性导致设计矩阵奇异:你使用的~ts:marks是仅包含交互项的模型,未纳入ts或marks的主效应。你的tessellation有4个瓦片,标记分2类,交互项会生成8个变量,加上截距项后,这些变量之间存在严格的线性依赖关系——比如所有瓦片的A、B类交互项组合与截距项可互相线性表示,导致方差-协方差矩阵不可逆,无法计算标准误,模型估计失效。
  • 空单元格加剧估计问题:模拟数据中存在部分瓦片内某类标记无点的情况(比如输出中tsTile row 2, col 2:marksB的系数为NA),这种完全分离的情况进一步破坏了设计矩阵的秩,直接导致部分系数无法估计。

解决方案

  • 加入主效应修正共线性:将模型公式改为完整交互模型~ ts + marks + ts:marks,或至少加入其中一个主效应(如~ marks + ts:marks、~ ts + ts:marks),这样能消除完全共线性,让设计矩阵满秩,模型可正常估计。
  • 处理空单元格问题:如果实际数据中存在大量空单元格,可通过合并瓦片(降低tessellation复杂度)、调整标记分类等方式,避免出现某瓦片内某类标记无点的完全分离情况。

内容的提问来源于stack exchange,提问作者agila

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 07:49:59