meanf中的错误 - 未使用的参数

时间:2016-07-11 01:57:49

标签: r forecasting

我使用预测包在R中编写的函数出现问题。这是功能:

    generateARIMAForecasts <- function(inputTSDecompList, inputArimaOrder, fcstHrzn, cnst, drft){

  tmpSTL <- NULL;
  fcasting <- NULL;
  tsfcastList <- NULL;
  counter <- 1;

  while(counter <= length(inputTSDecompList)){
    #select the TS decompositions
    tmpSTL <- inputTSDecompList[counter]$TimeSeriesDecomposition;
    #add the lattice plot to the list of plots
    if(cnst == TRUE & drft == TRUE){
      fcasting <- forecast(tmpSTL, h=fcstHrzn, 
                           forecastfunction=function(x,h,level, ...){
                           fit <- Arima(x, order=inputArimaOrder, include.constant = TRUE, include.drift = TRUE) 
                           return(forecast(fit,h=fcstHrzn,level=level, ...))});
    }
    fcastCoefs <- fcasting$model$coef;
    fcstValues <- fcasting;
    fcastSummary <- summary(fcasting);

    #add the forecast results to the forecast list
    tsfcastList[[counter]] <- list(FinancialInstitution=LVTSFITimeSeriesList[counter]$LVTSFITimeSeriesList$FinancialInstitution, 
                             ForecastCoefficients=fcastCoefs,
                             ForecastedSeries=fcstValues,
                             ForecastSummary=fcastSummary);
    counter <- counter+1;
  }
  return(tsfcastList); 
}

该函数采用STL分解序列列表,并为输入列表中每个单独的stl分解时间序列生成Arima预测。 我通过对单个元素进行硬编码手动运行预测生成,并且它可以正常运行。但是当我尝试使用该函数时,我得到以下错误

  

meanf中的错误(对象,h = h,level = level,fan = fan,lambda = lambda,:     未使用的参数(forecastfunction = function(x,h,level,...)   {       fit&lt; - Arima(x,order = inputArimaOrder,include.constant = TRUE,include.drift = TRUE)       return(预测(fit,h = fcstHrzn,level = level,...))   })   另外:有50个或更多警告(使用警告()查看前50个)

有人可以提出建议吗?

1 个答案:

答案 0 :(得分:1)

嗨,经过几个小时手动调试RStudio控制台中的每一行,我发现问题是我的电话

tmpSTL <- inputTSDecompList[counter]$TimeSeriesDecomposition;

这返回NULL,因为我使用

创建了inputTSDecompList作为二维列表
tsDecomList[[counter]] <- list(FinancialInstitution=inputTSList[counter]$LVTSFITimeSeriesList$FinancialInstitution, TimeSeriesDecomposition=tsDecom);

所以我本来应该打电话给

tmpSTL <- inputTSDecompList[[counter]]$TimeSeriesDecomposition;