Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: forecast::Arima() #910 #6

Open
englianhu opened this issue Jun 26, 2022 · 3 comments
Open

Error: forecast::Arima() #910 #6

englianhu opened this issue Jun 26, 2022 · 3 comments

Comments

@englianhu
Copy link
Owner

> 循环周期 <- 600
> 季回归 <- 培训数据$闭市价 %>% 
        matrix(dimnames = list(培训数据$年月日时分, '闭市价')) %>% 
        tk_ts(frequency = 循环周期)
      rownames(季回归) <- 培训数据$年月日时分
> 季回归
Time Series:
Start = c(1, 1) 
End = c(2, 600) 
Frequency = 600 
            闭市价
1451592060 120.208
1451592120 120.208
1451592180 120.208
1451592240 120.208
1451592300 120.208
1451592360 120.208
1451592420 120.208
1451592480 120.208
1451592540 120.208
1451592600 120.208
1451592660 120.208
1451592720 120.208
1451592780 120.208
1451592840 120.208
1451592900 120.208
1451592960 120.208
1451593020 120.208
1451593080 120.208
1451593140 120.208
1451593200 120.208
1451593260 120.208
1451593320 120.208
1451593380 120.208
1451593440 120.208
1451593500 120.208
1451593560 120.208
1451593620 120.208
1451593680 120.208
1451593740 120.208
1451593800 120.208
1451593860 120.208
1451593920 120.208
1451593980 120.208
1451594040 120.208
1451594100 120.208
1451594160 120.208
1451594220 120.208
1451594280 120.208
1451594340 120.208
1451594400 120.208
1451594460 120.208
1451594520 120.208
1451594580 120.208
1451594640 120.208
1451594700 120.208
1451594760 120.208
1451594820 120.208
1451594880 120.208
1451594940 120.208
1451595000 120.208
1451595060 120.208
1451595120 120.208
1451595180 120.208
1451595240 120.208
1451595300 120.208
1451595360 120.208
1451595420 120.208
1451595480 120.208
1451595540 120.208
1451595600 120.208
1451595660 120.208
1451595720 120.208
1451595780 120.208
1451595840 120.208
1451595900 120.208
1451595960 120.208
1451596020 120.208
1451596080 120.208
1451596140 120.208
1451596200 120.208
1451596260 120.208
1451596320 120.208
1451596380 120.208
1451596440 120.208
1451596500 120.208
1451596560 120.208
1451596620 120.208
1451596680 120.208
1451596740 120.208
1451596800 120.208
1451596860 120.208
1451596920 120.208
1451596980 120.208
1451597040 120.208
1451597100 120.208
1451597160 120.208
1451597220 120.208
1451597280 120.208
1451597340 120.208
1451597400 120.208
1451597460 120.208
1451597520 120.208
1451597580 120.208
1451597640 120.208
1451597700 120.208
1451597760 120.208
1451597820 120.208
1451597880 120.208
1451597940 120.208
1451598000 120.208
 [ reached getOption("max.print") -- omitted 1100 rows ]

Tried to build ts format seasonal dataset and forecast::Arima() but all errors, somebody take a look?

> Arima(季回归)
Error in solve.default(res$hessian * n.used, A) : 
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0
> Arima(季回归, order = c(3, 1, 0))
Error in optim(init[mask], armaCSS, method = optim.method, hessian = FALSE,  : 
  initial value in 'vmmin' is not finite
> Arima(季回归, order = c(2, 1, 0))
Error in optim(init[mask], armaCSS, method = optim.method, hessian = FALSE,  : 
  initial value in 'vmmin' is not finite
> Arima(季回归, order = c(2, 0, 0))
Error in stats::arima(x = x, order = order, seasonal = seasonal, include.mean = include.mean,  : 
  non-stationary AR part from CSS
> Arima(季回归, order = c(1, 0, 0))
Error in stats::arima(x = x, order = order, seasonal = seasonal, include.mean = include.mean,  : 
  non-stationary AR part from CSS
> Arima(季回归, order = c(0, 0, 0))
Error in solve.default(res$hessian * n.used, A) : 
  Lapack routine dgesv: system is exactly singular: U[1,1] = 0
> Arima(季回归, order = c(1, 1, 1))
Error in optim(init[mask], armaCSS, method = optim.method, hessian = FALSE,  : 
  initial value in 'vmmin' is not finite
> Arima(季回归, order = c(0, 1, 1))
Error in optim(init[mask], armaCSS, method = optim.method, hessian = FALSE,  : 
  initial value in 'vmmin' is not finite
> Arima(季回归, order = c(0, 0, 1))
Error in solve.default(res$hessian * n.used, A) : 
  system is computationally singular: reciprocal condition number = 4.19528e-25

Citation : robjhyndman/forecast#910 (comment)

@englianhu englianhu changed the title Error: Arima() #910 Error: forecast::Arima() #910 Jun 26, 2022
@englianhu
Copy link
Owner Author

englianhu commented Jan 1, 2023

✔ [世博量化研究院*]
❯ source('函数/日内高频季节性自回归.R')
✔ [世博量化研究院*]
❯ if (.模型选项 == '自动化') {
半成品 <- tryCatch({
auto.arima(
季回归, d = .差分阶数, D = .季节性差分阶数, seasonal = 季节性与否, 
stationary = 静态与否, trace = 记载自回归与否, 
ic = 信息量准则, stepwise = 逐步精化与否, nmodels = 逐步精化量, 
#approximation = 近似值与否, 
method = 计策谋略, truncate = 省略, #x = y, 
xreg = 趋势, test = 测试, lambda = 博克斯考克斯变换, 
test.args = 测试参数, allowdrift = 允许截距与否, 
seasonal.test = 季节性测试, seasonal.test.args = 季节性测试参数, 
allowmean = 允许包含均值与否, biasadj = 偏差调整与否, 
parallel = 多管齐下与否, num.cores = 核心量)
}, 错误信息 = function(错误信息参数) NULL)
半成品 <- 预测样本 |> 
{\(.) mutate_dt(., 市场价 = 闭市价, 预测价 = coef(半成品))}() |> 
{\(.) select_dt(., 年月日时分, 市场价, 预测价)}()
模型名称 <- paste0(
.模型选项, '_差分阶数_', .差分阶数, '_季节性差分阶数_', .季节性差分阶数, 
'_季节性与否_', 季节性与否, '_静态与否_', 静态与否, 
'_记载自回归与否_', 记载自回归与否, '_信息量准则_', 信息量准则, 
'_逐步精化与否_', 逐步精化与否, '_计策谋略_', 计策谋略, 
'_数据量', 数据量, 
'_频率', 频率, '_预测时间单位', 预测时间单位, 
'_', 预测样本$年月日时分, 'CST.rds')
}
✔ [世博量化研究院*]
❯ 信息量准则 = c('aicc', 'aic', 'bic')
✔ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = .时序规律, seasonal = .季节性规律参数, 
xreg = 趋势, include.mean = 包含均值与否, 
include.drift = 包含截距与否, #include.constant = 包含常数, 
#model = 统计模型, lambda = 博克斯考克斯变换, x = y, 
biasadj = 偏差调整与否, method = 计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in if ((order[2] + seasonal$order[2]) > 1 & include.drift) { : 
参数长度为零
✖ [世博量化研究院*]
❯   包含截距与否
[1] TRUE
✔ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = .时序规律, seasonal = .季节性规律参数, 
xreg = 趋势, include.mean = 包含均值与否, 
#include.drift = 包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in if ((order[2] + seasonal$order[2]) > 1 & include.drift) { :
参数长度为零
✖ [世博量化研究院*]
❯ .时序规律
[data.table]:
# A tibble: 108 × 3
自回归阶数 差分阶数 滑均阶数
<int>    <int>    <int>
1          0        0        0
2          0        0        1
3          0        0        2
4          0        0        3
5          0        0        4
6          0        0        5
7          0        1        0
8          0        1        1
9          0        1        2
10          0        1        3
# … with 98 more rows
# ℹ Use `print(n = ...)` to see more rows
✔ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]), seasonal = unlist(.季节性规律参数[1,]),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = 包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in solve.default(res$hessian * n.used, A) :
Lapack例行程序dgesv: 系统正好是奇异的: U[1,1] = 0
✖ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]),
seasonal = list(order = unlist(.季节性规律参数[1,]), period = 循环周期),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = 包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in solve.default(res$hessian * n.used, A) :
Lapack例行程序dgesv: 系统正好是奇异的: U[1,1] = 0
日内高频季节性自回归 <- function(
## ======== 居住在英国布里斯托尔港口,修读气象学系的英国基督洋妞儿芈拉不可以死 ========
    时间索引, 样本, .蜀道 = NULL, 文件名 = '日内高频季节性自回归', 数据量, 
    频率 = 1, 预测时间单位 = 1, .模型选项 = .模型选项, 
    .差分阶数 = .差分阶数, .季节性差分阶数 = .季节性差分阶数, 
    季节性与否 = 季节性与否, .时序规律 = .时序规律, 
    .季节性规律参数 = .季节性规律参数, 静态与否 = 静态与否, 
    记载自回归与否 = 记载自回归与否, 信息量准则 = c('aicc', 'aic', 'bic'), 
    逐步精化与否 = 逐步精化与否, 逐步精化量 = 逐步精化量, 
    #近似值与否 = (length(x) > 150 | frequency(x) > 12), 
    省略 = 省略, #x = y, method = NULL, 
    ## 代码中xreg作为 [公式] 。xreg可以指定多组相关序列,
    ##   也就是说动态回归就是多元回归。
    ## Dynamic Harmonic Regression
    ## 使用FT(傅里叶)序列作为xreg。模型拟合时不指定seasonal,
    ##   在预测时加入周期性的xreg(势头/趋势/气势)。
    ## [R语言时间序列分析(预测)](https://zhuanlan.zhihu.com/p/29755934)
    趋势 = 趋势, 测试 = 测试, 测试参数 = 测试参数, 
    季节性测试 = 季节性测试, 季节性测试参数 = 季节性测试参数, 
    允许截距与否 = 允许截距与否, 允许包含均值与否 = 允许包含均值与否, 
    博克斯考克斯变换 = 博克斯考克斯变换, 偏差调整与否 = 偏差调整与否, 
    多管齐下与否 = 多管齐下与否, 核心量 = 核心量, 包含均值与否 = 包含均值与否, 
    #趋势 = NULL, 包含常数与否, 
    包含截距与否 = 包含截距与否, 统计模型 = 统计模型, 
    #博克斯考克斯变换 = 统计模型$lambda, x = y, 偏差调整与否 = FALSE, 
    计策谋略 = 计策谋略, 列印 = '') {
...
...
...
}
✖ [世博量化研究院*]
❯ args(Arima)
function (y, order = c(0, 0, 0), seasonal = c(0, 0, 0), xreg = NULL,
include.mean = TRUE, include.drift = FALSE, include.constant,
lambda = model$lambda, biasadj = FALSE, method = c("CSS-ML",
"ML", "CSS"), model = NULL, x = y, ...)
NULL
<environment: R_GlobalEnv>
✔ [世博量化研究院*]
❯ 包含截距与否
[1] TRUE

包含截距与否 = 包含截距与否, 统计模型 = 统计模型,
#博克斯考克斯变换 = 统计模型$lambda, x = y, 偏差调整与否 = FALSE,
计策谋略 = 计策谋略, 列印 = '') {

https://github.com/robjhyndman/forecast/blob/5ced6bd1e53ed6d783ebed2108bab5cf1fa03a53/R/arima.R#L735-L738

735    if ((order[2] + seasonal$order[2]) > 1 & include.drift) {
736      warning("No drift term fitted as the order of difference is 2 or more.")
737      include.drift <- FALSE
738  }

Arima函数include.drift = FALSE默认值为FALSE,而包含截距与否 = "勾",咱不摸索include.drift的用途,先根据Arima函数默认值计算。

@englianhu
Copy link
Owner Author

englianhu commented Jan 1, 2023

愚忠入侵电子仪器反抗咱们全球NonMuslim中华民族、中国政府、台湾政府的所有巫裔回教徒911恐怖份子巫师巫婆太监民族和忠实狗奴才洋人回教徒Michael Cutter Christopher bin Abdullah阖家一律死刑

#大秦赋 #ChineseEmperor #一带一路路线图战略 #南太平洋战略 #巫裔是回教徒911恐怖份子 #可兰经回教刑事法典断肢法歼灭东南亚所有巫裔 #十二生肖 #ChineseZodiac #甲午战争 #辛丑条约 #辛亥革命

🚩🦔Great Britain = 大英帝国
🚩🦔Greater Chin = 大秦帝国/大秦赋
🚩🦔Greater Chinese = 大秦子民(爱民如子)
🚩🦔Oversea Greater Chinese = 海外大秦子民(爱民如子)
🚩🦔Oversea Greater Chinese Union = 海外大秦子民公会(秦始皇的秦太祖 ----- 🌟秦孝公/🌟陈祯禄公爵,联合秦始皇 ----- 秦始祖嬴政,爱民如子,商鞅变法断肢法铲除咱们巫裔回教徒911恐怖份子Judi回教博彩庄,终止巫术以任何形式、包括指鹿为马、屠杀人类,甚至铲除全球回教徒攻陷回教宗祖国麦家🕋🇹🇷🇸🇦瓦解全球回教,拯救全球)

愚忠效忠进肛门的安瓦bin Law的那些东南亚所有巫裔和《时光机器2002》的白骨精Extrem Jodoh爱新觉罗溥仪洋人回教徒911恐怖份子巫师巫婆太监民族Michael Cutter Christopher bin Law阖家(尤其是马来巫裔回教总警署的回教徒911恐怖份子巫师巫婆太监民族),愚忠去反抗中台政府一律依照可兰经回教刑事法典断肢法歼灭东南亚所有巫裔

愚忠毁约赔款给中国政府一带一路高铁的马哈第二和所有巫裔巫师巫婆太监民族党羽,导致民不聊生(各商场几乎都没人消费者、各行各业),不引入一带一路高铁发展运输贸易旅游就业经济,一律依照可兰经回教刑事法典断肢法处死。

咱们东南亚伪满州伪国民党所有巫裔回教徒911恐怖份子巫师巫婆太监民族(Extrem Jodoh白骨精巫师王回教徒爱新觉罗溥仪Michael Cutter Christopher bin Law)集体自杀,种族灭绝,即可拯救全球。

黄联富本人歼灭东南亚所有巫裔,直到推翻巫裔回教徒911恐怖份子巫师巫婆太监民族政权...

巫裔宦官,误国误民;
草菅人命,民不聊生。
歼灭巫裔,人人有责;
终止屠杀,拯救全球。
巫裔尽弃,瓦釜雷鸣;
不忘初心,放得始终。

陈水扁已经丧心病狂,在监狱中竟选择自残,最终只是哗众取宠

Arima(order, seasonal, xreg, include.drift, method...)

## .季节性规律参数 <- c(0, 0, 0)
.季节性规律参数 <- permutations(6, 3, 0:5, repeats.allowed = TRUE) %>%
as.data.table
.季节性规律参数 <- setnames(.季节性规律参数, old = c('V1', 'V2', 'V3'),
new = c('季节性自回归阶数', '季节性差分阶数', '季节性滑均阶数'))[季节性差分阶数 <= 2] %>%
mutate_dt(总和 = rowSums(.)) %>%
filter_dt(总和 > 0) %>%
select_dt(-总和)

❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]),
seasonal = list(order = unlist(.季节性规律参数[1,]), period = 循环周期),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = 包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in stats::arima(x = x, order = order, seasonal = seasonal, include.mean = include.mean,  :
'seasonal$order'必需是长度为三的非负数值矢量
✖ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]),
seasonal = unlist(.季节性规律参数[1,]),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = FALSE, #包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 'CSS')#计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in solve.default(res$hessian * n.used) :
Lapack例行程序dgesv: 系统正好是奇异的: U[1,1] = 0
❯ source('函数/日内高频季节性自回归.R')
✔ [世博量化研究院*]
❯ 计策谋略
[1] "CSS-ML" "ML"     "CSS"
✔ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]),
seasonal = unlist(.季节性规律参数[1,]),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = FALSE, #包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 'CSS')#计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in solve.default(res$hessian * n.used) :
Lapack例行程序dgesv: 系统正好是奇异的: U[1,1] = 0
✖ [世博量化研究院*]
❯ tryCatch({
Arima(
季回归, order = unlist(.时序规律[1,]),
seasonal = unlist(.季节性规律参数[1,]),
xreg = 趋势, include.mean = 包含均值与否,
include.drift = TRUE, #包含截距与否, #include.constant = 包含常数,
#model = 统计模型, lambda = 博克斯考克斯变换, x = y,
biasadj = 偏差调整与否, method = 'CSS')#计策谋略)
}, 错误信息 = function(错误信息参数) NULL)
Error in solve.default(res$hessian * n.used) :
Lapack例行程序dgesv: 系统正好是奇异的: U[1,1] = 0

相关资源:

@englianhu
Copy link
Owner Author

englianhu commented Jan 1, 2023

2.4 GiB [世博量化研究院*]
❯ 季回归0 <- llply(.差分阶数, function(差分阶数) {
        季回归1 <- llply(.季节性差分阶数, function(季节性差分阶数) {
            季回归2 <- llply(季节性与否, function(季节) {
                季回归3 <- llply(时间索引, function(时序) {
                    成效 <- 日内高频季节性自回归(
                        时间索引 = 时序, 样本 = 样本2018半年, .蜀道 = .蜀道, 
                        文件名 = '日内高频季节性自回归', 数据量 = 数据量, 频率 = 频率, 
                        预测时间单位 = 预测时间单位, .模型选项 = 模型, 
                        .差分阶数 = 差分阶数, .季节性差分阶数 = 季节性差分阶数, 
                        季节性与否 = 季节, 静态与否 = '', 记载自回归与否 = '', 
                        信息量准则 = c('aicc', 'aic', 'bic'), 逐步精化与否 = '', 
                        逐步精化量 = 94, #近似值与否=(length(x)>150|frequency(x)>12), 
                        省略 = NULL, 计策谋略 = NULL, #x = y, 
                        趋势 = NULL, 测试 = c('kpss', 'adf', 'pp'), 测试参数 = list(), 
                        季节性测试参数 = list(), 季节性测试 = c('seas', 'ocsb', 'hegy', 'ch'), 
                        允许截距与否 = '', 允许包含均值与否 = '', 
                        博克斯考克斯变换 = NULL, 偏差调整与否 = '', 多管齐下与否 = '', 核心量 = 2, 
                        包含均值与否 = '', 包含截距与否 = '')
                  }, .progress = 'text')
              }, .progress = 'text')
         }, .progress = 'text')
    }, .progress = 'text')
Error in { :
task 1 failed - "task 1 failed - "task 1 failed - "task 1 failed - "季节性与否 = ''''""""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant