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

Teradata® R Package Function Reference

Teradata R Package
September 2020
Programming Reference


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 function generates a model that the function td_lar_predict_mle uses to make predictions for the response variables.


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



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.


Required Argument.
Specifies the input tbl_teradata.
Note: All columns must be in lower case.


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


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 tbl_teradata) is 1532, and the intercept is 1, then the default value is 8*min(11, 1532 - 1) = 88.
Types: integer


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


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


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)


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

  1. output.table

  2. sql.stdout


    # 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 object(s) of class "tbl_teradata".
    diabetes <- tbl(con, "diabetes")
    # Rename columns in the tbl_teradata to lower case, since the input tbl_teradata
    # 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