@@ -34,9 +34,6 @@ randomizedLasso = function(X,
34
34
noise_scale = 0.5 * sd(y ) * sqrt(mean_diag )
35
35
}
36
36
37
- print(paste(" ridge term" , ridge_term ))
38
- print(paste(" noise scale" , noise_scale ))
39
-
40
37
noise_type = match.arg(noise_type )
41
38
42
39
if (noise_scale > 0 ) {
@@ -101,8 +98,8 @@ randomizedLasso = function(X,
101
98
observed_unpen = result $ soln [unpenalized ]
102
99
observed_subgrad = - n * result $ gradient [inactive ]
103
100
104
- if (length(which( abs(observed_subgrad )> lam [ 1 ])) ){
105
- print (" subgradient eq not satisfied" )
101
+ if (sum( abs(observed_subgrad )> lam * ( 1.001 )) > 0 ){
102
+ stop (" subgradient eq not satisfied" )
106
103
}
107
104
108
105
observed_opt_state = c(observed_unpen , observed_scalings , observed_subgrad )
@@ -355,15 +352,16 @@ conditional_density = function(noise_scale, lasso_soln) {
355
352
randomizedLassoInf = function (X ,
356
353
y ,
357
354
lam ,
358
- family = " gaussian" ,
359
- sampler = " A " ,
355
+ family = c( " gaussian" , " logistic " ) ,
356
+ sampler = c( " norejection " , " adaptMCMC " ) ,
360
357
sigma = NULL ,
361
358
noise_scale = NULL ,
362
359
ridge_term = NULL ,
363
360
condition_subgrad = TRUE ,
364
361
level = 0.9 ,
365
- nsample = 10000 ,
366
- burnin = 2000 ,
362
+ sampler = c(" norejection" , " adaptMCMC" ),
363
+ nsample = 10000 ,
364
+ burnin = 2000 ,
367
365
max_iter = 100 , # how many iterations for each optimization problem
368
366
kkt_tol = 1.e-4 , # tolerance for the KKT conditions
369
367
parameter_tol = 1.e-8 , # tolerance for relative convergence of parameter
@@ -376,6 +374,8 @@ randomizedLassoInf = function(X,
376
374
n = nrow(X )
377
375
p = ncol(X )
378
376
377
+ family = match.arg(family )
378
+
379
379
lasso_soln = randomizedLasso(X ,
380
380
y ,
381
381
lam ,
@@ -392,7 +392,7 @@ randomizedLassoInf = function(X,
392
392
393
393
active_set = lasso_soln $ active_set
394
394
nactive = length(active_set )
395
- print(paste( " nactive " , nactive ))
395
+
396
396
if (nactive == 0 ){
397
397
return (list (active_set = active_set , pvalues = c(), ci = c()))
398
398
}
@@ -418,10 +418,12 @@ randomizedLassoInf = function(X,
418
418
419
419
ndim = length(lasso_soln $ observed_opt_state )
420
420
421
- if (sampler == " R" ){
421
+ sampler = match.arg(sampler )
422
+
423
+ if (sampler == " adaptMCMC" ){
422
424
S = sample_opt_variables(lasso_soln , jump_scale = rep(1 / sqrt(n ), ndim ), nsample = nsample )
423
425
opt_samples = as.matrix(S $ samples [(burnin + 1 ): nsample ,,drop = FALSE ])
424
- } else if (sampler == " A " ) {
426
+ } else if (sampler == " norejection " ) {
425
427
opt_samples = gaussian_sampler(noise_scale ,
426
428
lasso_soln $ observed_opt_state ,
427
429
cur_opt_transform $ linear_term ,
0 commit comments