R 预测与拉普拉函数
我正在使用expsmooth软件包中的数据集和forecast软件包中的forecast函数组合进行造林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])
#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)) #<-----------------------