我能够使用Forecast()
画面中的功能进行预测。我有每日每小时数据(需求电力)。以前我使用以下代码:
SCRIPT_REAL("library(forecast);
jjearnts <- msts(.arg1, seasonal.periods=c(24, 7*24, 365*24));
fit <- tbats(jjearnts);
fcast <- forecast(fit,h=.arg2[1]);
n<-length(.arg1);
append(.arg1[(.arg2[1]+1):n],fcast$mean, after = n-.arg2[1])",
SUM([ Load demand(electricity)]),[ Parameter])
上面的代码有效,但它缺少一些虚拟预测器。所以我尝试了以下代码:
SCRIPT_REAL("library(forecast);
modelfitsample <- data.frame(.arg1,Weekday=rep(1:7,7);
xreg <- cbind(Weekday=model.matrix(~as.factor(modelfitsample$Weekday));
xreg <- xreg[,-1];
colnames(xreg) <- c("Mon","Tue","Wed","Thu","Fri","Sat");
jjearnts <-ts(modelfitsample$.arg1,frequency=24*365,start=c(2008,90));
fcast <- forecast(jjearnts, h=.arg2[1]);
n<-length(.arg1);
append(.arg1[(.arg2[1]+1):n],fcast$mean, after = n-.arg2[1])",
SUM([Load demand(electricity)]),[ Parameter])
此代码不起作用