| LINREG | R Documentation |
This function builds a linear regression model. Standard least square method, variable selection, factorial methods are available.
LINREG(
x,
y,
quali = c("none", "intercept", "slope", "both"),
reg = c("linear", "subset", "ridge", "lasso", "elastic", "pcr", "plsr"),
regeval = if (reg[1] == "subset") c("bic", "adjr2", "cp", "r2") else c("r2", "msep"),
scale = TRUE,
validation = c("CV", "LOO"),
lambda = 10^seq(-5, 5, length.out = 101),
alpha = 0.5,
nrep = 1,
tune = FALSE,
methodparameters = NULL,
graph = FALSE,
seed = NULL,
...
)
x |
Predictor |
y |
Response |
quali |
Indicates how to use the qualitative variables. |
reg |
The algorithm. |
regeval |
The criterion used to choose between models. For |
scale |
If true, PCR and PLS use scaled dataset. |
validation |
How the number of components of a PCR or PLS regression is chosen:
|
lambda |
The lambda parameter of Ridge, Lasso and Elastic net regression. |
alpha |
The elasticnet mixing parameter. |
nrep |
How many times the cross-validation choosing |
tune |
If true, the function returns parameters instead of a classification model. |
methodparameters |
Present for interface consistency with |
graph |
A logical indicating whether or not graphics should be plotted (ridge, LASSO and elastic net). |
seed |
A specified seed for random number generation, so that two runs on the same data give the same model. Every learning method accepts it, so that it can be set the same way whatever the method; the deterministic ones simply have nothing to draw and give the same model with or without it. |
... |
Other parameters. |
The classification model, as an object of class model-class.
lm, regsubsets, mvr, glmnet
## Not run:
require (datasets)
# With one independent variable
data (cars)
LINREG (cars [, -2], cars [, 2])
# With two independent variables
data (trees)
LINREG (trees [, -3], trees [, 3])
# With non numeric variables
data (ToothGrowth)
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], quali = "intercept") # Different intercept
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], quali = "slope") # Different slope
LINREG (ToothGrowth [, -1], ToothGrowth [, 1], quali = "both") # 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.