Description Usage Arguments Value Examples
Computes the gradient of the logistic regression error:
f(x) = 1/n sum_{i=1}^n ( log(1 + exp(- b_i * x' * A_i) ) ,
for a given design matrix
A
and a response binary vector b
with values +1
and
-1
.
1 | grad.logistic(x, opts)
|
x |
A p-dimensional vector where the gradient is computed. |
opts |
List of parameters, which must include:
|
The gradient of the function f(x) = 1/n sum_{i=1}^n ( log(1 + exp(- b_i * x' * A_i) ), which is:
f'(x) = 1/n sum_{i=1}^n -b_i A_i / (1 + exp( b_i * x' * A_i ))
1 2 3 4 | grad.logistic(c(1,3,-2), list(A=diag(3), b=c(1,-1,1))
# The following give the same (elastic net penalized logistic regression without offset):
glmnet(A,b,family="binomial",lambda=0.1,standardize=FALSE,intercept=FALSE, alpha=0.5)$b
apg(grad.logistic, prox.elasticnet, ncol(A), list(A=A, b=b, lambda=0.1, alpha=0.5) )$x
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.