Learn R Programming

rtemis (version 0.79)

lincoef: Linear Model Coefficients

Description

Get linear model coefficients

Usage

lincoef(x, y, weights = NULL, method = c("glmnet", "cv.glmnet",
  "lm.ridge", "allSubsets", "forwardStepwise", "backwardStepwise", "glm",
  "sgd", "solve"), alpha = 0, lambda = 0.01, lambda.seq = NULL,
  cv.glmnet.nfolds = 5, which.cv.glmnet.lambda = c("lambda.min",
  "lambda.1se"), nbest = 1, nvmax = 8, sgd.model = "glm",
  sgd.model.control = list(lambda1 = 0, lambda2 = 0),
  sgd.control = list(method = "ai-sgd"), ...)

Arguments

x

Features

y

Outcome

weights

Float, vector: Case weights

method

String: Method to use: "glm": uses stats::lm.wfit; "glmnet": uses glmnet::glmnet; "cv.glmnet": uses glmnet:cv.glmnet; "lm.ridge": uses MASS::lm.ridge; "allsubsets": uses leaps::regsubsets with method = "exhaustive"; "forwardStepwise": uses leaps::regsubsets with method = "forward}; "backwardStepwise": uses \code{leaps::regsubsets} with \code{method = "backward; "sgd": uses sgd::sgd "solve": uses base::solve

alpha

Float: alpha for method = glmnet or cv.glmnet. Default = 0

lambda

Float: The lambda value for glmnet, cv.glmnet, lm.ridge Note: For glmnet and cv.glmnet, this is the lambda used for prediction. Training uses lambda.seq. Default = .01

lambda.seq

Float, vector: lambda sequence for glmnet and cv.glmnet. Default = NULL

cv.glmnet.nfolds

Integer: Number of folds for cv.glmnet

which.cv.glmnet.lambda

String: Whitch lambda to pick from cv.glmnet: "lambda.min": Lambda that gives minimum cross-validated error;

nbest

Integer: For method = "allSubsets", number of subsets of each size to record. Default = 1

nvmax

Integer: For method = "allSubsets", maximum number of subsets to examine.

sgd.model

String: Model to use for method = "sgd". Default = "glm"

sgd.model.control

List: model.control list to pass to sgd::sgd

sgd.control

List: sgd.control list to pass to sgd::sgd

...

Additional parameters to pass to leaps::regsubsets "lambda.1se": Largest lambda such that error is within 1 s.e. of the minimum.

Value

Coefficients