Refactoring: generalize dynamic XXX
martin0258 opened this issue · 0 comments
martin0258 commented
The goal of this issue is to write a unified library for the _gradual forecast model
_ (逐集預測) in time series (i.e., a model is trained to predict each time period). The main differences are training/testing.
Type 1: Linear Regression, nnet, AadaboostR2 (regression model)
# predictor can be "lm", "nnet", "adaboostR2", etc.
model <- predictor(formula, data, ...)
prediction <- predict(model, newdata)
Type 2: Average N (time series model, no library)
# average
model <- averageN(x, ...) # There is only 1 parameter n for this model
prediction <- predict(model)
Type 3: AR (time series model)
# Training
model <- ar(x, ...)
# Testing
## S3 method for class 'ar'
### Why new data?
prediction <- predict(model, newdata,
n.ahead = 1, se.fit = TRUE, ...)$pred[1]
Type 4: Arima (time series model)
# Training
auto.arima(x, xreg = trainFeatures)
# Testing
prediction <- predict(model, n.ahead = 1, newxreg = NULL)$pred[1]
Type 5: Exponential Smoothing (time series model)
model <- HoltWinters(x, ...)
predict <- predict(model, n.ahead = 1)[1]
Type 6: Exponential Smoothing State Space (time series model)
model <- ets(x)
prediction <- predict(model, h=1)$mean[1]
Task
- add a function of type 1