Teradata R Package Function Reference - LinReg - Teradata R Package - Look here for syntax, methods and examples for the functions included in the Teradata R Package.

Teradata® R Package Function Reference

Product
Teradata R Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-28
dita:id
B700-4007
lifecycle
previous
Product Category
Teradata Vantage

Description

The Linear Regression (td_lin_reg_mle) 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
  )

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 object. 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 object that contains the dependent and independent columns for the linear regression model.

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 Teradata tbl object.
Named list member can be referenced directly with the "$" operator using name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("linearregression_example", "housing_data")
    
    # Create remote tibble objects.
    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)
                                )