Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 预测与拉普拉函数_R_Loops_Lapply_Forecast - Fatal编程技术网

R 预测与拉普拉函数

R 预测与拉普拉函数,r,loops,lapply,forecast,R,Loops,Lapply,Forecast,我正在使用expsmooth软件包中的数据集和forecast软件包中的forecast函数组合进行造林 #Example 1 require("forecast") require("expsmooth") # required for the data # Fit an ETS model to the first 45 months - Training set Training_set_model <- ets(usnetelec[1:45])

我正在使用expsmooth软件包中的数据集和forecast软件包中的forecast函数组合进行造林

#Example 1
    require("forecast")
    require("expsmooth") # required for the data

    # Fit an ETS model to the first 45 months - Training set
    Training_set_model <- ets(usnetelec[1:45])

    # Apply the same model to the last 10 months without re-estimating the parameters- Test set
    Test_set_model <- ets(usnetelec[46:55],model=Training_set_model)  #<--------------------------------
#示例1
要求(“预测”)
要求(“expsmooth”)#数据所需
#将ETS模型安装到前45个月-培训集

Training_set_model您可以尝试
Forecast_Test_set我尝试了这行代码,但出现了一些错误。出现消息“Error in Forecast_Training_set[[I]]:subscript out bounds”。请检查您是否对第一条评论感到抱歉,我认为
window()
函数返回了
list
对象。尝试使用
Forecast\u测试集
#Example 2
    library(fpp2)
    library(forecast)

    Data_Set<-uschange[,1:4]

    # Training set
    Training_set = window(Data_Set, start=1970, end=c(2010,4))

    # Test set
    Test_set = window(Data_Set, start=2011, end=c(2016,3))

    # Forecasting with Training set
    Forecast_Training_set<-lapply(Training_set, ets) 
   # Forecasting with Test set
    Forecast_Test_set<- lapply(Test_set, ets(model=Forecast_Training_set)) #<-----------------------