logreg.ridge.fit: logreg.ridge.fit

Description Usage Arguments Value Examples

View source: R/logreg.ridge.fit.R

Description

This function takes y,x and lambda to perform a logistic regression w/wo l2 penalty The input data should be a numeric matrix without factoer level, though we can use the transform method to encode it. This function will return a list including coefficients of estimates, yhat, and predicted class, and classification error

Usage

1
2
3
4
5
6
7
8
logreg.ridge.fit(
  y,
  X,
  lambda,
  epochs = 10,
  tol = 1e-05,
  beta0 = rep(0, dim(X)[2])
)

Arguments

y

input y, this is the label of the class, it should be a vector of either zero or one

X

input X, this is a matrix of training X.

lambda

the coefficient of how severe the penalty should be

epochs

this value specifies how much iteration will we do to update our coefficients

tol

this input means tolerance, which determines early stop in training

beta0

this is the initialization of beta estimators, sometimes user may want to further train a specific beta, and they can use it as input.

Value

it will return a list of estimated coefficients, the predicted score y.hat, the predicted class yhat and classification error.

Examples

1
2
3
x=matrix(rnorm(100),20,5)
y=sample(c(0,1),20,replace=TRUE)
logreg.ridge.fit(y,x,lambda=0)

chenyn16/LogisticRidge documentation built on Dec. 31, 2020, 9:58 p.m.