TD_MAMEAN Function Examples | Teradata Vantage - TD_MAMEAN 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

TD_MAMEAN Input Table Orders1

StoreID SEQ Sales
101 3 203.0
101 5 205.0
101 4 204.0
101 2 202.0
101 1 201.0
... ... ...

Example: TD_MAMEAN Call

EXECUTE FUNCTION INTO VOLATILE ART(MAMEAN_RESULTS)
TD_MAMEAN(
   SERIES_SPEC(TABLE_NAME(Orders1),SERIES_ID(storeID),
      ROW_AXIS(SEQUENCE(SEQ)),
      PAYLOAD( FIELDS(sales), CONTENT(REAL))),
   FUNC_PARAMS(FORECAST_PERIODS(8), ALGORITHM(MA),
      PREDICTION_INTERVALS('BOTH'),
      FIT_METRICS(1), RESIDUALS(1), K_ORDER(3))
);

TD_MAMEAN Primary Output

SELECT * FROM MAMEAN_RESULTS;
StoreID ROW_I OBSERVED_VALUE FORECAST_VALUE LO_80 HI_80 LO_95 HI_95
-----------------------------------------------------------------------------
101 0 2.01000000000000E 002 2.01000000000000E 002 ? ? ? ?
101 1 2.02000000000000E 002 2.02000000000000E 002 ? ? ? ?
101 2 2.03000000000000E 002 2.02000000000000E 002 ? ? ? ?
101 3 2.04000000000000E 002 2.03000000000000E 002 ? ? ? ?
101 4 2.05000000000000E 002 2.04000000000000E 002 ? ? ? ?
101 5 2.06000000000000E 002 2.05000000000000E 002 ? ? ? ?
101 6 2.07000000000000E 002 2.06000000000000E 002 ? ? ? ?
101 7 2.08000000000000E 002 2.07000000000000E 002 ? ? ? ?
101 8 2.09000000000000E 002 2.08000000000000E 002 ? ? ? ?
101 9 2.10000000000000E 002 2.09000000000000E 002 ? ? ? ?
101 10 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 11 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 12 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 13 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 14 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 15 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 16 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002
101 17 ? 2.09000000000000E 002 2.02445134511657E 002 2.14554865488343E 002 1.98596332090601E 002 2.18403667909399E 002

Example: TD_MAMEAN Secondary Call

CREATE TABLE MA_RESIDUALS AS (
EXECUTE FUNCTION
TD_EXTRACT_RESULTS( 
   ART_SPEC(TABLE_NAME(MAMEAN_RESULTS), 
   LAYER(ARTFITRESIDUALS)))) WITH DATA
;

TD_MAMEAN Secondary Output

SELECT * FROM MA_RESIDUALS;
StoreID ROW_I ACTUAL_VALUE CALC_VALUE RESIDUAL
----------- -------------------- ---------------------- ---------------------- ----------------------
101 2 2.03000000000000E 002 2.02000000000000E 002 1.00000000000000E 000
101 4 2.05000000000000E 002 2.04000000000000E 002 1.00000000000000E 000
101 5 2.06000000000000E 002 2.05000000000000E 002 1.00000000000000E 000
101 6 2.07000000000000E 002 2.06000000000000E 002 1.00000000000000E 000
101 8 2.09000000000000E 002 2.08000000000000E 002 1.00000000000000E 000
101 9 2.10000000000000E 002 2.09000000000000E 002 1.00000000000000E 000
101 7 2.08000000000000E 002 2.07000000000000E 002 1.00000000000000E 000
101 3 2.04000000000000E 002 2.03000000000000E 002 1.00000000000000E 000
101 1 2.02000000000000E 002 2.02000000000000E 002 0.00000000000000E 000
101 0 2.01000000000000E 002 2.01000000000000E 002 0.00000000000000E 000

Example: TD_MAMEAN Tertiary Call

CREATE TABLE MA_FITMETRICS AS (
EXECUTE FUNCTION
TD_EXTRACT_RESULTS( ART_SPEC(TABLE_NAME(MAMEAN_RESULTS), LAYER(ARTFITMETADATA) ) ) ) WITH DATA;

TD_MAMEAN Tertiary Output

SELECT * FROM MA_FITMETRICS;
StoreID 101
ROW_I 0
NUM_SAMPLES 10
VAR_COUNT 2
R_SQUARE 6.92307692307692E-001
R_ADJ_SQUARE 5.38461538461538E-001
STD_ERROR 2.00000000000000E 000
STD_ERROR_DF 8
ME 1.00000000000000E 000
MAE 1.00000000000000E 000
MSE 1.00000000000000E 000
MPE 4.79630098480213E-001
MAPE 4.79630098480213E-001
FSTAT_CALC 4.50000000000000E 000
P_VALUE 1.67949705662156E-001
NUM_DF 1
DENOM_DF 2
SIGNIFICANCE_LEVEL 5.00000000000000E-002
F_CRITICAL 1.85128205128205E 001
F_CRITICAL_P 5.00000000000000E-002
NULL_HYPOTH ACCEPT