This class is used for interpolating or predicting missing data in a time series using the Auto ARIMA algorithm.
Depending on the constructor that is used, the data and auto ARIMA models are set up for either interpolation or prediction. The interpolation is interpolate(). The prediction methods is predict().
Interpolate will fill a gap in the data, whose start is specified by gap_loc and whose length is specified by N_gap. Data is assumed to be of equal time steps, and is split into two parts, data_before and data_after. So in the end data should be of size data_before + data_after + N_gap. The interpolation is done by fitting one ARIMA model to data_before and one to data_after. The ARIMA models are fitted using the auto.arima algorithm from the ctsa (BSD-3 Clause, see below). The ARIMA models are then used to predict the missing data forward and backward in time. The final prediction is a weighted average of the two, where the weighting is done so more information comes from the closer data.
Predict will predict the next n_steps values in the time series. It can either be forward in time (direction = "forward") or backward in time (direction = "backward"). For forward prediction data[0:gap_loc] is used to fit the ARIMA model, and for backward prediction data[gap_loc + N_gap:] is used.
For more Information concerning ARIMA see, Wikipedia, and Forecast documentation, and the final interpolation algorithm: Time weighted average
- Note
- Interpolate is meant to only be used, when there is actually backward data available. If there is no backward data, then predict should be used instead. Where predict is meant to be used in conjunction with the according constructor. Currently prediction forward or backward, when providing both is not implemented, but can be easily added on demand.
- Author
- Patrick Leibersperger
- Date
- 2024-01-25
Copyright (c) 2014, Rafat Hussain All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| InterpolARIMA () |
|
| InterpolARIMA (std::vector< double > data_in, size_t gap_loc, size_t N_gap, int s=0) |
| Main Constructor for an InterpolARIMA object. Used to fill 1 gap in the data. More...
|
|
| InterpolARIMA (std::vector< double > data_in, size_t gap_loc, size_t N_gap, std::vector< double > xreg_vec, int s=0) |
| This constructor is used to initialize an InterpolARIMA object for filling a gap in the data with exogenous variables. More...
|
|
| InterpolARIMA (std::vector< double > data_in, size_t gap_loc, size_t n_predictions, std::string direction="forward", int s=0) |
| This constructor is used to initialize an InterpolARIMA object for making predictions ahead or backward in time. More...
|
|
void | setAutoArimaMetaData (int max_p_param=8, int max_d_param=3, int max_q=8, int start_p=2, int start_q=2, int max_P=2, int max_D=1, int max_Q=2, int start_P=1, int start_Q=1, bool seasonal=true, bool stationary=false) |
|
void | setOptMetaData (ObjectiveFunction method=CSS_MLE, OptimizationMethod opt_method=BFGS, bool stepwise=true, bool approximation=false, int num_models=94) |
|
void | setVerbose (bool verbose=false) |
|
void | setNormalizationMode (Normalization::Mode mode) |
|
void | setManualARIMA (int p, int d, int q, int P, int D, int Q, bool fill_backward) |
|
std::vector< double > | simulate (int n_steps, int seed=0) |
|
void | fillGap () |
|
void | fillGapManual () |
|
void | interpolate () |
|
std::vector< double > | predict (size_t n_steps=0) |
|
std::vector< double > | ARIMApredict (size_t n_steps) |
|
std::vector< double > | getData () |
|
std::vector< double > | getForwardData () |
|
std::vector< double > | getBackwardData () |
|
std::vector< double > | getInterpolatedData () |
|
| InterpolARIMA (const InterpolARIMA &other) |
|
InterpolARIMA & | operator= (const InterpolARIMA &other) |
|
| ~InterpolARIMA () |
|
std::string | toString () |
|
std::string | autoArimaInfo (auto_arima_object obj) |
|