mtsdi中的arima方法

mtsdi中的arima方法,r,time-series,R,Time Series,我有一个很大的数据集(超过2000行和2000个变量),其中有很多缺少的值。我使用R的mtsdi包的mnimput函数来插补所有缺失值。这是我的密码 formula = data imput_out <- mnimput(formula,data, by = NULL, log = FALSE, log.offset = 1, eps = 1e-3, maxit = 1e2, ts = TRUE, method = "arima", ar.control

我有一个很大的数据集(超过2000行和2000个变量),其中有很多缺少的值。我使用R的mtsdi包的
mnimput
函数来插补所有缺失值。这是我的密码

formula = data
imput_out <- mnimput(formula,data, by = NULL, log = FALSE, log.offset = 1,
                 eps = 1e-3, maxit = 1e2, ts = TRUE, method = "arima", ar.control = list(order = c(1,1,1), period = 4,  f.eps = 1e-6, f.maxit = 1e3, ga.bf.eps = 1e-6,verbose = TRUE, digits = getOption("digits")))

请帮帮我。

您必须深入了解软件包的来源,才能发现这里发生了什么。 将ar.control放入一个变量o中,该变量由放入公式中的列的j#进行迭代。因此,如果您的公式看起来像
~c31+c32+c33
,则ar项需要是3列(p,d,q)值

为了便于编辑,我在ar.control参数之外指定了它
arcontrol
Error in o[1:3, j] : incorrect number of dimensions
mnimput(formula,data,eps=1e-3,ts=TRUE, method="arima", ar.control=arcontrol
function (xn, o, s, eps, maxit) 
{
  rows <- dim(xn)[1]
  cols <- dim(xn)[2]
  models <- as.list(rep(NA, cols))
  ar.pred <- matrix(NA, nrow = rows, ncol = cols)
  for (j in 1:cols) {
    if (is.null(s)) {
      order <- o[1:3, j]
      seasonal <- list(order = c(0, 0, 0), period = NA)
    }
    else {
      order <- o[1:3, j]
      seasonal <- list(order = o[4:6, j], period = s)
    }
    models[[j]] <- arima(xn[, j], order = order, seasonal = seasonal, 
      xreg = NULL, optim.control = list(maxit = maxit, 
        reltol = eps))
    ar.pred[, j] <- xn[, j] - residuals(models[[j]])
  }
  retval <- list(ar.pred = ar.pred, models = models)
  return(retval)
}