2016-07-11 2 views
0

예상 패키지를 사용하여 R에 쓴 함수에 문제가 있습니다. 함수가 입력리스트에서 시계열 분해 개별 STL마다 아리마 예측 시리즈 분해 STL리스트를 취하고, 생성meanf - 사용되지 않은 인수에 오류가 발생했습니다.

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); 
} 

:이 함수이다. 개별 요소에 대한 하드 코딩을 통해 수동으로 예측 생성을 실행했으며 작동합니다. 되지 않은 인수 (forecastfunction = 나는 다음과 같은 오류를 meanf (객체, 시간 = h를, 레벨 = 레벨, 팬 = 팬, 람다 = 람다에서

오류를 얻을 기능을 사용하여 수행하려고하지만 경우 함수 (x, h, level, ...) { fit < - Arima (x, order = inputArimaOrder, include.constant = TRUE, include.drift = TRUE) return (예측 (적합, h = fcstHrzn, 수준 레벨 = ...))} ) 이외에 50 이상의 경고가 있었다 (사용 경고()를 참조하는 제 50)

누군가 조언 해 주시겠습니까? 수동으로 RStudio 콘솔에서 각 행을 디버깅 몇 시간, 내가 그것을 알아 낸 후

답변

0

안녕하세요 문제는 내가 2 차원 목록으로 inputTSDecompList을 창조했기 때문에 이것은 NULL을 반환

tmpSTL <- inputTSDecompList[counter]$TimeSeriesDecomposition; 

내 전화했다 그래서

tmpSTL <- inputTSDecompList[[counter]]$TimeSeriesDecomposition; 
를 호출되어 있어야합니다
tsDecomList[[counter]] <- list(FinancialInstitution=inputTSList[counter]$LVTSFITimeSeriesList$FinancialInstitution, TimeSeriesDecomposition=tsDecom); 

를 사용하여