cbergmeir / Rlgt

Rlgt is an R package for Bayesian Exponential Smoothing
20 stars 11 forks source link

when using with seasonality with regressors, error occurs #7

Open yonoklee opened 8 months ago

yonoklee commented 8 months ago

theDataSet=AirPassengers frequency(theDataSet)

horizon=2*frequency(theDataSet) train=theDataSet[1:(length(theDataSet)-horizon)] #forecast the last horizon of the series actuals=theDataSet[(length(theDataSet)+1-horizon):length(theDataSet)]

reg.data = matrix(rnorm(length(theDataSet))) reg.train = reg.data[1:(length(theDataSet)-horizon)] reg.test = reg.data[(length(theDataSet)+1-horizon):length(theDataSet)]

rstanmodel = rlgt(train, seasonality=frequency(theDataSet), level.method="seasAvg", xreg = reg.train, control=rlgt.control(NUM_OF_ITER=10000))

forec = forecast(rstanmodel, reg.test, h = 24)

Error in regFittedS[(length(regFittedS) - seasonality_int + 1):length(regFittedS)] : only 0's may be mixed with negative subscripts