You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I understand the code correctly, when beta differed from 0 in the previous iteration but is then reduced to 0 in this iteration, s will permanently be incorrect.
Hence, if beta and beta_old are not equal, one would want to update
s<-s+XX[,j]*( beta[j] -beta_old[j])
(if this is indeed a bug, one might hope that it doesn't affect results much if it is relatively rare for coefficients to go from non-zero to zero)
But it might be difficult to detect numerically if beta and beta_old are equal, such that maybe one always wants to update, e.g.
if (S0>lambda)
beta[j] <- (lambda-S0)/XX[j, j]
if (S0<-1*lambda)
beta[j] <- (-1*lambda-S0)/XX[j, j]
if (abs(S0) <=lambda)
beta[j] <-0s<-s+XX[,j]*( beta[j] -beta_old[j])
(and maybe it would be ever-so-slightly faster to use if ... else if ... else ..., with the first check being the case abs(S0) <= lambda)
The text was updated successfully, but these errors were encountered:
In the gradient descent code, if
S0
is small (in absolute value) such that the coefficient is set to 0, why isn'ts
(= XX %*% beta
) updated?BDcocolasso/R/lasso_covariance.R
Lines 63 to 72 in e883bb3
If I understand the code correctly, when
beta
differed from 0 in the previous iteration but is then reduced to 0 in this iteration,s
will permanently be incorrect.Hence, if
beta
andbeta_old
are not equal, one would want to update(if this is indeed a bug, one might hope that it doesn't affect results much if it is relatively rare for coefficients to go from non-zero to zero)
But it might be difficult to detect numerically if
beta
andbeta_old
are equal, such that maybe one always wants to update, e.g.(and maybe it would be ever-so-slightly faster to use if ... else if ... else ..., with the first check being the case abs(S0) <= lambda)
The text was updated successfully, but these errors were encountered: