Teradata Package for Python Function Reference | 20.00 - BreuschPaganGodfrey - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00.00.03
Published
December 2024
Language
English (United States)
Last Update
2024-12-19
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
 
 
BreuschPaganGodfrey

 
Functions
       
BreuschPaganGodfrey(data=None, data_filter_expr=None, variables_count=None, formula=None, studentize=False, significance_level=0.05, **generic_arguments)
DESCRIPTION:
    The BreuschPaganGodfrey() function checks for heteroscedasticity using 
    one or more variables among the residual terms after running a regression.
 
    The following procedure is an example of how to use BreuschPaganGodfrey() function:
        * Use MultivarRegr() to create regression model and generate residuals.
        * Use BreuschPaganGodfrey() on the output DataFrame from MultivarRegr().
        * Check the 'NULL_HYPOTHESIS' value to determine if there is heteroscedasticity. 
          ACCEPT means that variance is homoscedastic. 
          REJECT means that variance is heteroscedastic.       
        
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the residual multivariate series or 
        TDAnalyticResult object created over output 
        generated by the UAF regression function.
        Types: TDSeries, TDAnalyticResult
 
    data_filter_expr:
        Optional Argument.
        Specifies the filter expression for "data".
        Types: ColumnExpression
 
    variables_count:
        Required Argument.
        Specifies the number of explanatory variables 
        that are used in the auxiliary regression.
        Types: int
 
    formula:
        Optional Argument.
        Specifies the regression formula to use for the 
        auxiliary regression. If a formula is not included, 
        then the default regression formula is used.
        Types: str
 
    studentize:
        Optional Argument.
        Specifies whether to use the Koenker studentized 
        version of the Breusch-Pagan-Godfrey (BPG) test.   
        When set to True, Koenker studentized version is 
        used, otherwise the standard BPG test is used.
        Default Value: False
        Types: bool
 
    significance_level:
        Optional Argument.
        Specifies the desired significance level for the test.
        Default Value: 0.05
        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 BreuschPaganGodfrey.
    Output teradataml DataFrames can be accessed using attribute 
    references, such as BreuschPaganGodfrey_obj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        1. result
 
 
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", ["house_values"])
 
    # Create teradataml DataFrame object.
    data = DataFrame.from_table("house_values")
 
    # Create teradataml TDSeries object.
    data_series_df = TDSeries(data=data,
                              id="cityid",
                              row_index="TD_TIMECODE",
                              payload_field=["house_val","salary","mortgage"],
                              payload_content="MULTIVAR_REAL")
 
    # Create Multivariate regression model.
    mvr_out = MultivarRegr(data=data_series_df,
                           variables_count=3,
                           weights=False,
                           formula="Y = B0 + B1*X1 + B2*X2",
                           algorithm='QR',
                           coeff_stats=True,
                           model_stats=True,
                           residuals=True)
    
    # Example 1: Perform Breusch-Pagan-Godfrey (BPG) test using input as teradataml 
    #            TDSeries object generated from model residuals.
    # Extract residuals from the model as TDSeries.
    data_series_bg = TDSeries(data=mvr_out.fitresiduals,
                              id="cityid",
                              row_index="ROW_I",
                              row_index_style= "SEQUENCE",
                              payload_field=["RESIDUAL","ACTUAL_VALUE","CALC_VALUE"],
                              payload_content="MULTIVAR_REAL")
    uaf_out = BreuschPaganGodfrey(data=data_series_bg,
                                  variables_count=2,
                                  significance_level=0.01)
 
    # Print the result DataFrame.
    print(uaf_out.result)
    
    # Example 2: Perform Koenker studentized version of the Breusch-Pagan-Godfrey 
    #            (BPG) test using input as teradataml TDAnalyticResult object
    #            generated from model output.
    # Create teradataml TDAnalyticResult object from model output.
    data_art_df =  TDAnalyticResult(data=mvr_out.result)
    uaf_out = BreuschPaganGodfrey(data=data_art_df,
                                  variables_count=2,
                                  studentize=True,
                                  significance_level=0.01)
 
    # Print the result DataFrame.
    print(uaf_out.result)