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

升级R版本后seasonal包seas()函数执行失败求助

R4.2.2中seasonal::seas()执行失败:奇异协方差矩阵错误解决建议

问题背景

将应用从Python3.6/R3.4.4/Ubuntu18.04迁移至Python3.9/R4.2.2/Debian Bookworm后,seasonal包的seas()函数在处理特定时间序列时失败,报错如下:

Error: X-13 run failed

Errors:
- The covariance matrix of the ARMA parameters is singular;
  cannot compute t-statistics for the ARMA parameters. Program
  error(s) halt execution for
  /tmp/RtmpCk2llq/x13393485b3fa137/iofile.spc

该序列在R3.4.4环境下可正常执行,且另一组数据集在两个环境下均无问题。

解决方法

1. 手动指定ARMA模型结构

旧环境中成功的模型对应ARMA结构为**(0,1,1)(1,0,1)12**(非季节性MA(1),季节性AR(1)+MA(1),一阶非季节性差分),直接指定该结构绕过自动模型选择:

library("seasonal")

data = c(88.7, 89.0, 89.5, 89.9, 90.2, 90.5, 90.1, 90.8, 90.8, 90.9, 91.1, 91.7, 91.4, 92.0, 92.4, 93.2, 93.2, 93.0, 93.0, 93.6, 93.8, 93.9, 94.0, 94.5, 93.8, 94.3, 94.6, 95.2, 95.3, 95.0, 95.1, 95.5, 95.8, 96.4, 96.5, 96.7, 95.9, 96.4, 96.9, 97.0, 97.4, 97.2, 97.0, 97.5, 97.9, 98.1, 98.2, 98.4, 97.4, 98.1, 98.4, 99.0, 98.9, 99.2, 98.8, 99.3, 99.4, 99.6, 99.4, 99.6, 98.8, 99.3, 99.5, 99.7, 99.9, 99.9, 99.9, 100.3, 100.4, 100.7, 100.7, 101.0, 100.0, 100.4, 101.0, 100.9, 101.1, 101.3, 101.2, 101.6, 101.9, 101.9, 102.1, 102.6, 101.6, 102.4, 102.8, 103.4, 103.7, 103.8, 103.7, 104.3, 104.6, 104.6, 104.9, 105.2, 104.3, 104.9, 105.1, 105.5, 105.9, 105.7, 105.6, 106.5, 106.5, 106.5, 106.8, 107.2, 106.3, 106.9, 107.1, 107.4, 107.7, 107.6, 107.7, 108.1, 108.3, 108.4, 108.6, 108.6, 108.0, 108.6, 108.8, 108.9, 109.0, 109.2, 109.7, 109.0, 109.7, 109.9, 109.8, 110.1, 109.6, 109.6, 110.0, 110.3, 111.1, 111.7, 111.7, 112.5, 112.9, 113.7, 114.2, 114.8, 114.4, 115.3, 116.3, 117.1, 117.7, 118.2, 118.6, 119.5, 120.2, 121.0, 121.4, 122.1, 121.0, 122.4, 123.5, 125.1, 126.1, 126.3, 126.7, 126.9, 127.5, 127.9, 127.6, 128.3, 127.1, 127.9, 128.7, 129.9, 130.5, 130.8, 130.9, 131.5, 131.6, 132.1, 132.1, 132.4, 131.9, 132.4, 133.1, 134.7458499483, 135.2327015929, 135.4159773557, 135.6323765742, 136.1550422742, 136.3911489199, 136.8179029858, 136.8813759958, 137.5241597399, 136.433086938, 137.1452096555, 137.8572796109)
z <- ts(data, frequency=12, start = c(2010,1))

# 手动指定ARMA模型结构,同时保留旧环境中的异常值和节日调整
seas(z, 
     arima = "(0,1,1)(1,0,1)",
     xreg = list(
       easter = list(type = "td", shift = 8),
       ao = c("2020-07")
     )
)

原理:新版本seasonal的自动模型选择逻辑更严格,可能选择了参数冗余的模型引发协方差矩阵奇异,复用旧环境验证有效的模型结构可直接解决问题。

2. 强制X-13忽略奇异协方差错误

通过spec参数传递X-13的force命令,让程序跳过t统计量计算继续执行:

seas(z, spec = "force")

原理:适合不需要参数显著性检验的场景,直接输出模型结果。

3. 调整异常值检测逻辑

关闭自动异常值检测,减少模型参数数量避免共线性:

seas(z, outlier = list(method = "none"))

若需保留特定异常值,可手动指定而非依赖自动检测:

seas(z, outlier = list(ao = c("2020-07")))

4. 更新seasonal包至最新版本

检查并更新seasonal包,新版本可能修复了模型选择的兼容性问题:

install.packages("seasonal")
library("seasonal")

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 04:24:54