Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

LINREG

Linear Regression


Description

This function builds a linear regression model. Standard least square method, variable selection, factorial methods are available.

Usage

LINREG(
  x,
  y,
  formula = ".",
  reg = c("linear", "subset", "ridge", "lasso", "elastic", "pcr", "plsr"),
  regeval = c("r2", "bic", "adjr2", "cp", "msep"),
  scale = TRUE,
  lambda = 10^seq(-5, 5, length.out = 101),
  alpha = 0.5,
  graph = TRUE,
  tune = FALSE,
  ...
)

Arguments

x

Predictor matrix.

y

Response vector.

formula

A symbolic description of the model to be fitted (as a character string).

reg

The algorithm.

regeval

The evaluation criterion for subset selection.

scale

If true, PCR and PLS use scaled dataset.

lambda

The lambda parameter of Ridge, Lasso and Elastic net regression.

alpha

The elasticnet mixing parameter.

graph

A logical indicating whether or not graphics should be plotted (ridge, LASSO and elastic net).

tune

If true, the function returns paramters instead of a classification model.

...

Other parameters.

Value

The classification model, as an object of class model-class.

See Also

Examples

## Not run: 
require (datasets)
# With one independant variable
data (cars)
LINREG (cars [, -2], cars [, 2])
# With two independant variables
data (trees)
LINREG (trees [, -3], trees [, 3])
# With non numeric variables
data (ToothGrowth)
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], formula = "-1+supp+dose") # Different intersept
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], formula = "dose:supp") # Different slope
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], formula = "-1+supp+dose:supp") # Complete model
# With multiple numeric variables
data (mtcars)
LINREG (mtcars [, -1], mtcars [, 1])
LINREG (mtcars [, -1], mtcars [, 1], reg = "subset", regeval = "adjr2")
LINREG (mtcars [, -1], mtcars [, 1], reg = "ridge")
LINREG (mtcars [, -1], mtcars [, 1], reg = "lasso")
LINREG (mtcars [, -1], mtcars [, 1], reg = "elastic")
LINREG (mtcars [, -1], mtcars [, 1], reg = "pcr")
LINREG (mtcars [, -1], mtcars [, 1], reg = "plsr")

## End(Not run)

fdm2id

Data Mining and R Programming for Beginners

v0.9.5
GPL-3
Authors
Alexandre Blansché [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.