def test_auto_arima(self): fc = wrappers.auto_arima(self.oil) self.assertAlmostEqual(fc.point_fc[2011], 475.7004, places=3) self.assertAlmostEqual(fc.point_fc[2020], 547.0531, places=3) self.assertAlmostEqual(fc.lower80[2011], 412.6839, places=3) self.assertAlmostEqual(fc.upper95[2020], 851.8193, places=3) fc = wrappers.auto_arima(self.aus) self.assertAlmostEqual(fc.point_fc[(2011, 1)], 60.64208, places=3) self.assertAlmostEqual(fc.point_fc[(2012, 4)], 51.55356, places=3) self.assertAlmostEqual(fc.lower80[(2011, 1)], 57.57010, places=3) self.assertAlmostEqual(fc.upper95[(2012, 4)], 57.52426, places=3) self.assertRaises(ValueError, wrappers.auto_arima, self.oil , xreg=range(len(self.oil))) self.assertRaises(ValueError, wrappers.auto_arima, self.oil, h=10, newxreg=range(10))
''' This example shows automatic fitting of an arima model with a linear trend as a regressor. It is based on a post on Hyndsight, a blog by R Forecast package author Rob J. Hyndman. See: http://robjhyndman.com/hyndsight/piecewise-linear-trends/#more-3413 ''' # Not needed if the package is installed import sys, os sys.path.append(os.path.abspath('..')) from rforecast import ts_io from rforecast import wrappers from rforecast import converters from rforecast import plots # This is how to import data that is installed in R. stock = ts_io.read_ts('livestock', 'fpp') n = len(stock) fc = wrappers.auto_arima(stock, xreg=range(n), newxreg=range(n, n + 10)) print 'Australia livestock population 1961-2007' print stock plots.plot_ts(stock) print '10-year forecast of livestock population' print fc plots.plot_forecast(fc, stock)
def test_auto_arima_seasonal(self): fc_py = wrappers.auto_arima(self.aus_py) model = self.fc.auto_arima(self.aus_r) fc_r = self.fc.forecast(model) self._check_points(fc_py, fc_r)