linear_regression: Fit a 'linear_regression'

View source: R/linear_regression-fit.R

linear_regressionR Documentation

Fit a linear_regression

Description

linear_regression() fits a model.

Usage

linear_regression(x, ...)

## Default S3 method:
linear_regression(x, ...)

## S3 method for class 'data.frame'
linear_regression(x, y, ...)

## S3 method for class 'matrix'
linear_regression(x, y, ...)

## S3 method for class 'formula'
linear_regression(formula, data, ...)

## S3 method for class 'recipe'
linear_regression(x, data, ...)

Arguments

x

Depending on the context:

  • A data frame of predictors.

  • A matrix of predictors.

  • A recipe specifying a set of preprocessing steps created from recipes::recipe().

...

Not currently used, but required for extensibility.

y

When x is a data frame or matrix, y is the outcome specified as:

  • A data frame with 1 numeric column.

  • A matrix with 1 numeric column.

  • A numeric vector.

formula

A formula specifying the outcome terms on the left-hand side, and the predictor terms on the right-hand side.

data

When a recipe or formula is used, data is specified as:

  • A data frame containing both the predictors and the outcome.

Value

A linear_regression object.

Examples

set.seed(0)
data <- simulate_dummy_linear_data()

model <- linear_regression(y~., data, l1=0.05, l2=0.01, frob=0.01, num_comp=3)
model

new_data <- simulate_dummy_linear_data()

predict(model, new_data, type = "numeric")

jlaria/glasp documentation built on Dec. 5, 2022, 6:42 a.m.