Error R auto.arima

I am new to R and use the auto.arima function with xreg . I found the code on the network and tried to replicate the data. However, I get 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 read some answers to similar queries, but could not find a solution for my code. Please, help.

+6
source share
1 answer

One possible reason for this error is that your regressors are not linearly independent. The linear independence of the regressors (full rank of the regression matrix) is usually required for regression procedures.

Examples of violations of this assumption:

  • Including the X variable and the multiple aX constant in your model.
  • Including a column of all zeros in your model. This is a special case of (1), where a = 0.

If you do not want to verify independence manually, you can use the rankMatrix function in the Matrix package. If your regressors are linearly independent, your matrix will have a β€œfull rank”, which means that the rank is equal to the number of columns.

That is, the result of rankMatrix(xreg) should be ncol(xreg) .

+5
source

Source: https://habr.com/ru/post/953250/


All Articles