lincoef: Linear Model Coefficients

View source: R/lincoef.R

lincoefR Documentation

Linear Model Coefficients

Description

Get linear model coefficients

Usage

lincoef(
  x,
  y,
  weights = NULL,
  method = "glmnet",
  type = c("Regression", "Classification", "Survival"),
  learning.rate = 1,
  alpha = 1,
  lambda = 0.05,
  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"),
  trace = 0
)

Arguments

x

Feature matrix or data.frame. Will be coerced to data.frame for method = "allSubsets", "forwardStepwise", or "backwardStepwise"

y

Outcome

weights

Float, vector: Case weights

method

Character: 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 leaps::regsubsets with method = "backward"

  • "sgd": uses sgd::sgd

  • "solve": uses base::solve

  • "none": fits no model and returns all zeroes, for programming convenience in special cases

type

Character: "Regression", "Classification", or "Survival"

learning.rate

Numeric: Coefficients will be multiplied by this number

alpha

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

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.

lambda.seq

Float, vector: lambda sequence for glmnet and cv.glmnet.

cv.glmnet.nfolds

Integer: Number of folds for cv.glmnet

which.cv.glmnet.lambda

Character: 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

Character: Model to use for method = "sgd".

sgd.model.control

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

sgd.control

List: sgd.control list to pass to sgd::sgd "lambda.1se": Largest lambda such that error is within 1 s.e. of the minimum.

trace

Integer: If set to zero, all warnings are ignored

Details

This function minimizes checks for speed. It doesn't check dimensionality of x. Only use methods "glm", "sgd", or "solve" if there is only one feature in x.

Value

Named numeric vector of linear coefficients

Author(s)

E.D. Gennatas


egenn/rtemis documentation built on June 13, 2024, 7:33 p.m.