Determines parameters of a multiplicative seasonal autoregressive integrated moving average (ARIMA) model, and produces forecasts that incorporate the effects of outliers that have effects that persist beyond the end of the series.
TS_AUTO_ARIMA( <time_value>, <timeseries_expression> [ , <max_lag> [ , <critical > [ , epsilon> [ , <criterion> [ , <confidence> [, <model> [ , <n_predictions>]]]]]]] ) OVER (window-spec)
As an OLAP-style aggregate function, TS_AUTO_ARIMA produces a single SQL result—a specially encoded variable-length binary result value. Supporting scalar functions accept the binary composite output value and return individual scalar result values from it.
Since an OLAP-style aggregate function returns one result value per input tuple, the same binary composite result is returned for each row within a partition. If you do not specify a PARTITION BY clause in the OVER clause, use SELECT FIRST to reduce the results down to a single tuple containing the binary composite result. If you do specify a PARTITION BY clause in the OVER clause, use SELECT DISTINCT to eliminate all but one tuple per partition.
Mappings to the parameters of the IMSL C functions in the external VNI library are performed by the TS_AUTO_ARIMA_RESULT supporting scalar functions.
In this example, Sybase IQ computes the AUTO_ARIMA model independently for each of the four stock symbols. The DISTINCT qualifier reduces the set of tuples to one tuple per stock symbol. Finally, one output row is returned containing the stock symbol and all the relevant information describing the AUTO_ARIMA model computed for that stock.
select stock_symbol, TS_AUTO_ARIMA_RESULT_RESIDUAL_SIGMA( auto_arima_res ), TS_AUTO_ARIMA_RESULT_AIC( auto_arima_res), TS_AUTO_ARIMA_RESULT_AICC( auto_arima_res), TS_AUTO_ARIMA_RESULT_BIC( auto_arima_res), TS_AUTO_ARIMA_RESULT_FORECAST_VALUE( auto_arima_res, 1), TS_AUTO_ARIMA_RESULT_FORECAST_ERROR( auto_arima_res, 1), TS_AUTO_ARIMA_RESULT_FORECAST_VALUE( auto_arima_res, 2), TS_AUTO_ARIMA_RESULT_FORECAST_ERROR( auto_arima_res, 2),
TS_AUTO_ARIMA_RESULT_FORECAST_VALUE( auto_arima_res, 3),
TS_AUTO_ARIMA_RESULT_FORECAST_ERROR( auto_arima_res, 3),
TS_AUTO_ARIMA_RESULT_MODEL_P( auto_arima_res), TS_AUTO_ARIMA_RESULT_MODEL_Q( auto_arima_res),
TS_AUTO_ARIMA_RESULT_MODEL_S( auto_arima_res),
TS_AUTO_ARIMA_RESULT_MODEL_D( auto_arima_res) from ( select distinct stock_symbol, TS_AUTO_ARIMA(stock_trade_time, trade_price,
1, 3.0, 4.0, 0, 95.0, TS_INT_ARRAY(4, 0, 1, 0, 3)) over (partition by stock_symbol order by stock_trade_time) as auto_arima_res from stock_trades where stock_symbol in ('XYZ', 'XZZ', 'ZXZ', 'ZZZ') ) as auto_arima_per_stock