TD_LINEAR_REGR Function Examples | Teradata Vantage - TD_LINEAR_REGR Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743

Example: TD_LINEAR_REGR Call

EXECUTE FUNCTION INTO VOLATILE ART (DFES_EXAMPLE)
  TD_LINEAR_REGR (
    SERIES_SPEC (
      TABLE_NAME (HOUSE_VALUES),
      ROW_AXIS (SEQUENCE (S_NO)),
      SERIES_ID (CID),
      PAYLOAD (
        FIELDS (HOUSE_VALUE, SALARY),
        CONTENT (MULTIVAR_REAL)
    )
  ),
  FUNC_PARAMS (
    VARIABLES_COUNT (2),
    WEIGHTS (0),
    FORMULA ('Y = B0 + B1*X1'),
    ALGORITHM ('QR'),
    COEFF_STATS (1),
    MODEL_STATS (1),
    RESIDUALS (1)
  )
);

TD_LINEAR_REGR Primary Result

Display the primary RETURNS TABLE with this statement:

SELECT * FROM DFES_EXAMPLE;
             BuoyID 33
              ROW_I 0
         COEFF_NAME c
        COEFF_VALUE 6.49283216783218E 001
          STD_ERROR 5.08410244846500E-001
        TSTAT_VALUE 1.27708523454174E 002
         TSTAT_PROB 0.00000000000000E 000
      SIGNIF_RATING 0 to 0.001
       CONF_INT_LOW 6.40068478750983E 001
      CONF_INT_HIGH 6.58497954815452E 001
             BuoyID 33
              ROW_I 1
         COEFF_NAME a
        COEFF_VALUE 6.34965034965033E-001
          STD_ERROR 2.14047708095402E-002
        TSTAT_VALUE 2.96646500266206E 001
         TSTAT_PROB 7.53397344510631E-012
      SIGNIF_RATING 0 to 0.001
       CONF_INT_LOW 5.96169720030047E-001
      CONF_INT_HIGH 6.73760349900019E-001

Example: TD_LINEAR_REGR Secondary Call

Display the secondary RETURNS TABLE with this function call:

EXECUTE FUNCTION
  TD_EXTRACT_RESULTS (
    ART_SPEC (
      TABLE_NAME (DFES_EXAMPLE),
      LAYER (ARTFITMETADATA)
    )
 );

TD_LINEAR_REGR Secondary Result

CID   ROW_I              X1   ACTUAL_VALUE     CALC_VALUE       RESIDUAL
----  ------  -------------  -------------  -------------  -------------
  33       0   3.90000E 004   1.20000E 005   1.14708E 005   5.29101E 003
  33       1   5.00000E 004   1.44000E 005   1.42888E 005   1.11188E 003
  33       2   7.60000E 004   2.20000E 005   2.09493E 005   1.05066E 004
  33       3   2.20000E 004   8.00000E 004   7.11594E 004   8.84058E 003
  33       4   4.90000E 004   1.84000E 005   1.40326E 005   4.36736E 004
  33       5   1.12000E 005   3.20000E 005   3.01715E 005   1.82840E 004
  33       6   2.90000E 004   6.60000E 004   8.90915E 004  -2.30915E 004
  33       7   7.40000E 004   1.44000E 005   2.04369E 005  -6.03698E 004
  33       8   7.20000E 004   1.95000E 005   1.99246E 005  -4.24637E 003