| |
- CumulPeriodogram(data=None, data_filter_expr=None, significance_level=None, **generic_arguments)
- DESCRIPTION:
The CumulPeriodogram() function is used to perform a cumulative periodogram
statistics test, also known as Bartlett's test, to determine
the optimal data model. The series sample set is divided into two portions:
* The first portion is used for the 'model fitting' exercise.
* The second portion is used for the 'model validation'
exercise. CumulPeriodogram() function is usually
executed against the residuals produced during the second
'model validation' exercise, meaning against the
'in-sample' forecasted data points.
CumulPeriodogram() is similar to the SignifPeriodicities() function,
but the CumulPeriodogram() function tests periodicities at the same time
instead of sequentially.
The following procedure is an example of how to use CumulPeriodogram():
1. Use ArimaEstimate() to identify spectral candidates.
2. Use ArimaValidate() to validate spectral candidates.
4. Execute CumulPeriodogram() using the residuals.
5. See the null hypothesis result from CumulPeriodogram().
6. Use DataFrame.plot() to plot the results.
PARAMETERS:
data:
Required Argument.
Specifies a single univariate series with calculated residuals
from original regression or TDAnalyticResult object over the
output containing residuals generated by the UAF functions.
Types: TDSeries, TDAnalyticResult
data_filter_expr:
Optional Argument.
Specifies the filter expression for "data".
Types: ColumnExpression
significance_level:
Required Argument.
Specifies the significance level to be associated with the test.
Permitted Values: 0.05, 0.01
Types: float
**generic_arguments:
Specifies the generic keyword arguments of UAF functions.
Below are the generic keyword arguments:
persist:
Optional Argument.
Specifies whether to persist the results of the
function in a table or not. When set to True,
results are persisted in a table; otherwise,
results are garbage collected at the end of the
session.
Note that, when UAF function is executed, an
analytic result table (ART) is created.
Default Value: False
Types: bool
volatile:
Optional Argument.
Specifies whether to put the results of the
function in a volatile ART or not. When set to
True, results are stored in a volatile ART,
otherwise not.
Default Value: False
Types: bool
output_table_name:
Optional Argument.
Specifies the name of the table to store results.
If not specified, a unique table name is internally
generated.
Types: str
output_db_name:
Optional Argument.
Specifies the name of the database to create output
table into. If not specified, table is created into
database specified by the user at the time of context
creation or configuration parameter. Argument is ignored,
if "output_table_name" is not specified.
Types: str
RETURNS:
Instance of CumulPeriodogram.
Output teradataml DataFrames can be accessed using attribute
references, such as CumulPeriodogram_obj.<attribute_name>.
Output teradataml DataFrame attribute names are:
1. result
2. cpdata
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
# Notes:
# 1. Get the connection to Vantage to execute the function.
# 2. One must import the required functions mentioned in
# the example from teradataml.
# 3. Function will raise error if not supported on the Vantage
# user is connected to.
# Check the list of available UAF analytic functions.
display_analytic_functions(type="UAF")
# Load the example data.
load_example_data("uaf", "timeseriesdatasetsd4")
# Create teradataml DataFrame object.
df = DataFrame("timeseriesdatasetsd4")
# Create teradataml TDSeries object over 'df' dataframe.
td_series = TDSeries(data = df,
id="dataset_id",
row_index="seqno",
row_index_style="SEQUENCE",
payload_field = "magnitude",
payload_content="REAL")
# Create a filter expression to filter the dataset using dataset_id 552.
filter_expr = df.dataset_id==552
# Perform parameter estimation using ArimaEstimate() function.
arima_estimate = ArimaEstimate(data1=td_series,
data_filter_expr=filter_expr,
nonseasonal_model_order=[2, 0, 0],
constant=True,
algorithm="MLE",
fit_percentage=70,
fit_metrics=True,
coeff_stats=True,
residuals=True,
max_iterations=100)
# Create TDAnalyticResult object on the result attribute of arima_estimate
# generated by ArimaEstimate() function.
art_inp = TDAnalyticResult(arima_estimate.result)
# Validate the 'goodness of fit' of the model using ArimaValidate() function.
arima_validate = ArimaValidate(data=art_inp,
fit_metrics=True,
residuals=True)
# Example 1: Perform statistical test using CumulPeriodogram()
# with input as TDSeries object created over the 'fitresiduals'
# attribute of arima_validate generated by running ArimaValidate() and
# with a significance level of 0.05.
# Create teradataml TDSeries object on the 'fitresiduals' attribute of arima_validate
# generated by ArimaValidate() function.
data_series_df = TDSeries(data=arima_validate.fitresiduals,
id="dataset_id",
row_index="ROW_I",
row_index_style="SEQUENCE",
payload_field="RESIDUAL",
payload_content="REAL")
uaf_out = CumulPeriodogram(data=data_series_df,
significance_level=0.05)
# Print the result DataFrames.
print(uaf_out.result)
print(uaf_out.cpdata)
# Example 2: Perform statistical test using CumulPeriodogram()
# with input as TDAnalyticResult object created over
# the result attribute of arima_validate
# generated by ArimaValidate() function and
# with a significance level of 0.05.
# Create teradataml TDAnalyticResult object on the result attribute of arima_validate
# generated by ArimaValidate() function with layer as 'ARTFITRESIDUALS'.
art_df = TDAnalyticResult(data=arima_validate.result, layer="ARTFITRESIDUALS")
uaf_out = CumulPeriodogram(data=art_df,
significance_level=0.05)
# Print the result DataFrames.
print(uaf_out.result)
print(uaf_out.cpdata)
|