Teradata R Package Function Reference - LAR - 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

Least angle regression (LAR) and its most important modification, least absolute shrinkage and selection operator (LASSO), are variants of linear regression that select the most important variables, one by one, and fit the coefficients dynamically.
The td_lar_mle function generates a model that the function td_lar_predict_mle uses to make predictions for the response variables.

Usage

  td_lar_mle (
      formula = NULL,
      data = NULL,
      type = "LASSO",
      max.steps  = NULL,
      normalize = TRUE,
      intercept = TRUE,
      data.sequence.column = NULL
  )

Arguments

formula

Required Argument.
Specifies the model to be fitted, an object of class "formula". Only basic formula of the form (col1 ~ col2 + col3 +...) are supported, and all variables must be valid columns in "data" argument. The response should be a column of type real, numeric, integer or boolean.

data

Required Argument.
Specifies the input tbl object of class "tbl_teradata".
Note: All columns must be in lower case.

type

Optional Argument.
Specifies either "LAR" (least angle regression) or "LASSO".
Default Value: "LASSO". Permitted Values: LAR, LASSO

max.steps

Optional Argument.
Specifies the maximum number of steps the function executes. The default value is 8*min(number_of_predictors, sample_size - intercept). For example, if the number of predictors is 11, the sample size (number of rows in the input table) is 1532, and the intercept is 1, then the default value is 8*min(11, 1532 - 1) = 88.

normalize

Optional Argument.
Specifies whether each predictor is standardized to have unit L2 norm.
Default Value: TRUE

intercept

Optional Argument.
Specifies whether an intercept is included in the model (and not penalized).
Default Value: TRUE

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.

Value

Function returns an object of class "td_lar_mle" which is a named list containing Teradata tbl objects. Named list members can be referenced directly with the "$" operator using following names:

  1. output.table

  2. sql.stdout

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    # This input is diabetes data from "Least Angle Regression," by Bradley Efron and others.
    # This data set is atypical in that each predictor has mean 0 and norm 1
    loadExampleData("lar_example", "diabetes")
    
    # Create remote tibble objects.
    diabetes <- tbl(con, "diabetes")
    # Rename columns in the tbl object to lower case, since the input table
    # contains one or more column names in upper case.
    diabetes_lower <- diabetes %>% rename_all(tolower)

    # Example - Build a LAR model with response variable 'y' and ten baseline predictors
    td_lar_out <- td_lar_mle(formula = (y ~ hdl + glu + ldl + map1 + sex + tch + age + ltg
                                    + bmi + tc),
                         data = diabetes_lower,
                         type = "LAR",
                         max.steps  = 20,
                         intercept = TRUE
                         )