Teradata R Package Function Reference | 17.00 - 17.00 - LinReg - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

The Linear Regression function is composed of the functions Linear Regression and Linear Regression Internal. Linear Regression Internal function takes a data set and outputs a linear regression model. Linear Regression function takes the linear regression model and outputs its coefficients. One of the output model coefficient corresponds to the slope intercept. The function ignores input rows with NULL values.

Usage

  td_lin_reg_mle (
      formula = NULL,
      data = NULL,
      data.sequence.column = NULL,
      data.order.column = NULL
  )

Arguments

formula

Required Argument.
An object of class "formula". Specifies the model to be fitted. Only basic formula of the (y ~ x1 + x2 +... + xn) form are supported and all dependent and independent variables must be from the same input tbl_teradata. The target column or dependent variable must be of numeric type. Specifying the independent variables is optional, in which case the formula should be specified in the following format (y ~ .). If the independent variables are specified using a dot (.) symbol, then all columns in the input tbl_teradata other than the column specifying the dependent variable is used for prediction.

data

Required Argument.
Specifies the input tbl_teradata that contains the dependent and independent columns for the linear regression model.

data.order.column

Optional Argument.
Specifies Order By columns for "data".
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_lin_reg_mle" which is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator using the name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("linearregression_example", "housing_data")

    # Create object(s) of class "tbl_teradata".
    housing_data <- tbl(con, "housing_data")

    # Example 1 - This example uses the Linear Regression function
    # to find the coefficients of the independent variables that
    # determine the selling price of a home in a given neighborhood.
    td_lin_reg_out <- td_lin_reg_mle(data = housing_data,
                                 formula = (sellingprice ~ housesize + lotsize + bedrooms 
                                            + granite + upgradedbathroom)
                                )