简体   繁体   English

R auto.arima错误

[英]R auto.arima error

I am new to R and have using auto.arima function with xreg . 我是新来的R和已经使用auto.arima与功能xreg I found a code on the net and tried to replicate for my data. 我在网上找到了一个代码并试图复制我的数据。 However, I am getting the following error messages: 但是,我收到以下错误消息:

Error in optim(init[mask], armaCSS, method = optim.method, hessian = FALSE,  : 
  non-finite value supplied by optim

Error in if (diffs == 1 & constant) { : argument is of length zero
In addition: Warning message:
In auto.arima(salesTS, xreg = xreg1) : Unable to calculate AIC offset

My code is as follows: 我的代码如下:

data <- read.csv("C:/Users/s.karkala.rao/Documents/Projects/ad-hoc/Hitesh/forARIMAX.csv", header=TRUE, stringsAsFactors=TRUE)
subdata <- subset(data, data$NG.code == "101451")
subdata <- subdata[, -1]
salesTS <- ts(subdata$Sales.Qty, frequency=7)
xreg1 <- subdata[,-1]
xreg1 <- xreg1[, -10]
xreg1 <- as.matrix(xreg1)
model <- auto.arima(salesTS, xreg=xreg1)

I have read some of the answers on the similar queries, but couldn't figure out the solution for my code. 我已经阅读了类似查询的一些答案,但无法找到我的代码的解决方案。 Please help. 请帮忙。

One possible cause for this error is that your regressors are not linearly independent. 导致此错误的一个可能原因是您的回归量不是线性独立的。 Linear independence of regressors (aka full rank of the regression matrix) is typically required for regression procedures. 回归程序通常需要回归量的线性独立性(回归矩阵的完全等级)。

Examples of violating this assumption: 违反此假设的示例:

  1. Including a variable X and a constant multiple aX in your model. 在模型中包含变量X和常量多个aX。
  2. Including a column of all zeroes in your model. 在模型中包含一列全零。 This is a special case of (1), where a=0. 这是(1)的特例,其中a = 0。

If you don't want to check independence manually, you can use the rankMatrix function in the "Matrix" package. 如果您不想手动检查独立性,可以使用“Matrix”包中的rankMatrix函数。 If your regressors are linearly independent, your matrix will have "full rank", meaning rank equal to the number of columns. 如果您的回归量是线性独立的,那么您的矩阵将具有“满级”,意味着等级等于列数。

That is, the result of rankMatrix(xreg) should equal ncol(xreg) . 也就是说, rankMatrix(xreg)的结果应该等于ncol(xreg)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM