Reputation: 23
I am working on large dataset using auto.arima. The dataset is rich on zeros. most of the problems with rank deficient is ok but, i still can't figure how to deal with 'NN type' of data. It is very simmilar to 'PP type' (which it computes ok). NN type is very rare in my data. Any ideas how to fix this, or at least how make fast detection of NN type?
library(forecast)
NN<-matrix(c(2, 2,2, 1, 1,1 ,
0, 0,0,0,0,1 ,
0, 0,0,1,1,0),
nrow=6)
PP<-matrix(c(2, 2,2, 1, 1,1 ,
0, 0,0,0,0,1 ,
0, 0,1,1,1,0),
nrow=6)
qty<-rpois(6,3000)
auto.arima(qty)
auto.arima(qty, xreg=PP)
auto.arima(qty, xreg=NN)
Upvotes: 2
Views: 1195
Reputation: 24272
Analysing the code of the auto.arima
function, it is easy to find the code used for checking the rank deficiency of matrices. I suggest the following function:
is.rankdeficient <- function(xregg) {
constant_columns <- apply(xregg, 2, is.constant)
if (any(constant_columns)) {
xregg <- xregg[, -which(constant_columns)[1]]
}
sv <- svd(na.omit(cbind(rep(1, NROW(xregg)), xregg)))$d
min(sv)/sum(sv) < .Machine$double.eps
}
is.rankdeficient(PP)
# [1] FALSE
is.rankdeficient(NN)
# [1] TRUE
Upvotes: 1