AUTOREGRESSOR
Creates an autoregressive (AR) model from a stationary time series with consistent timesteps that can then be used for prediction via PREDICT_AUTOREGRESSOR.
Autoregressive models predict future values of a time series based on the preceding values. More specifically, the userspecified lag determines how many previous timesteps it takes into account during computation, and predicted values are linear combinations of the values at each lag.
Since its input data must be sorted by timestamp, this algorithm is singlethreaded.
This is a metafunction. You must call metafunctions in a toplevel SELECT statement.
Behavior type
VolatileSyntax
AUTOREGRESSOR ('modelname', 'inputrelation', 'datacolumn', 'timestampcolumn'
[ USING PARAMETERS
[ p = lags ]
[, method = 'trainingalgorithm' ]
[, missing = 'imputationmethod' ]
[, regularization = 'regularizationmethod' ]
[, lambda = regularizationvalue ]
[, compute_mse = boolean ]
] )
Arguments
modelname
 Identifies the model to create, where
modelname
conforms to conventions described in Identifiers. It must also be unique among all names of sequences, tables, projections, views, and models within the same schema. inputrelation
 The table or view containing the
timestampcolumn
.This algorithm expects a stationary time series as input; using a time series with a mean that shifts over time may lead to weaker results.
datacolumn
 An input column of type NUMERIC that contains the dependent variables or outcomes.
timestampcolumn
 One INTEGER, FLOAT, or TIMESTAMP column that represents the timestamp variable. Timesteps must be consistent.
Parameters
p
 INTEGER in the range [1, 1999], the number of lags to consider in the computation. Larger values for
p
weaken the correlation.Note
The AUTOREGRESSOR and ARIMA models use different training techniques that produce distinct models when trained with matching parameter values on the same data. For example, if you train an autoregressor model using the same data andp
value as an ARIMA model trained withd
andq
parameters set to zero, those two models will not be identical.Default: 3
method
 One of the following algorithms for training the model:

'OLS' (Ordinary Least Squares)

'YuleWalker'
Note
If you train a model with the YuleWalker algorithm, the alpha constant in the trained model is set to 0.0.Default: 'OLS'

missing
 One of the following methods for handling missing values:

'drop': Missing values are ignored.

'error': Missing values raise an error.

'zero': Missing values are replaced with 0.

'linear_interpolation': Missing values are replaced by linearlyinterpolated values based on the nearest valid entries before and after the missing value. This means that in cases where the first or last values in a dataset are missing, they will simply be dropped.
Default: ' linear_interpolation'

regularization
 One of the following regularization methods used when fitting the data:

None

'L2': Weight regularization term which penalizes the squared weight value
Default: None

lambda
 FLOAT in the range [0, 100000], the regularization value, lambda.
Default: 1.0
compute_mse
 BOOLEAN, whether to calculate and output the mean squared error (MSE).
Default: False
Examples
The following example creates and trains an autoregression model using the YuleWalker training algorithm and a lag of 3:
=> SELECT AUTOREGRESSOR('AR_temperature_yw', 'temp_data', 'Temperature', 'time' USING PARAMETERS p=3, method='yulewalker');
AUTOREGRESSOR

Finished. 3650 elements accepted, 0 elements rejected.
(1 row)
See Autoregressive model example for a walkthrough of how to train and make predictions with an autoregression model.