Skip to content

Commit 157c1db

Browse files
author
Jelena Markovic
committed
E of zero length
1 parent ce13171 commit 157c1db

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

selectiveInference/R/funs.randomized.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ randomizedLasso = function(X,
114114
X_E = X[,E]
115115
X_I = X[,I]
116116

117+
if (length(E)==0){
118+
return(list(active_set=c()))
119+
}
120+
117121
if (family=="binomial"){
118122
unpen_reg = glm(y~X_E-1, family="binomial")
119123
unpen_est = unpen_reg$coefficients
@@ -126,6 +130,7 @@ randomizedLasso = function(X,
126130
} else if (family=="gaussian"){
127131
W_E = diag(rep(1,n))
128132
}
133+
129134
L_E = t(X) %*% W_E %*% X[,E]
130135

131136
coef_term = L_E

tests/randomized/test_instances.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test_KKT=function(){
7171

7272

7373
collect_results = function(n,p,s, nsim=100, level=0.9,
74-
family = "gaussian",
74+
family = "binomial",
7575
condition_subgrad=FALSE, lam=1.2){
7676

7777
rho=0.3
@@ -115,7 +115,7 @@ collect_results = function(n,p,s, nsim=100, level=0.9,
115115
}
116116

117117
set.seed(1)
118-
collect_results(n=100, p=20, s=0, lam=0.5)
118+
collect_results(n=100, p=20, s=0, lam=0.8)
119119
#test_randomized_lasso()
120120
#test_KKT()
121121

0 commit comments

Comments
 (0)