@@ -109,6 +109,7 @@ randomizedLasso = function(X,
109
109
L_E = t(X ) %*% X [,E ]
110
110
111
111
coef_term = L_E
112
+
112
113
signs_ = c(rep(1 , sum(unpenalized )), sign_soln [active ])
113
114
if (length(signs_ ) == 1 ) {
114
115
coef_term = coef_term * signs_
@@ -344,6 +345,9 @@ randomizedLassoInf = function(X,
344
345
parameter_stop = parameter_stop )
345
346
346
347
active_set = lasso_soln $ active_set
348
+ if (length(active_set )== 0 ){
349
+ return (list (active_set = active_set , pvalues = c(), ci = c()))
350
+ }
347
351
inactive_set = lasso_soln $ inactive_set
348
352
nactive = length(active_set )
349
353
@@ -378,32 +382,61 @@ randomizedLassoInf = function(X,
378
382
379
383
pvalues = rep(0 , nactive )
380
384
ci = matrix (0 , nactive , 2 )
385
+
381
386
for (i in 1 : nactive ){
387
+
382
388
target_transform = linear_decomposition(observed_target [i ],
383
389
observed_internal ,
384
390
target_cov [i ,i ],
385
391
cov_target_internal [,i ],
386
392
internal_transform )
387
- target_sample = rnorm(nrow(opt_samples )) * sqrt(target_cov [i ,i ])
388
393
394
+
395
+ # changing dimension of density evalutaion
396
+
397
+ if ((condition_subgrad == TRUE ) & (nactive < p )) {
398
+ target_opt_linear = cbind(target_transform $ linear_term , opt_transform $ linear_term )
399
+ reduced_target_opt_linear = chol(t(target_opt_linear ) %*% target_opt_linear )
400
+ target_linear = reduced_target_opt_linear [,1 ]
401
+ temp = solve(t(reduced_target_opt_linear )) %*% t(target_opt_linear )
402
+ target_offset = temp %*% target_transform $ offset_term
403
+ target_transform = list (linear_term = as.matrix(target_linear ), offset_term = target_offset )
404
+ cur_linear = reduced_target_opt_linear [,2 : ncol(reduced_target_opt_linear )]
405
+ cur_offset = temp %*% opt_transform $ offset_term
406
+ cur_transform = list (linear_term = as.matrix(cur_linear ), offset_term = cur_offset )
407
+
408
+ raw = target_transform $ linear_term * observed_target [i ] + target_transform $ offset_term
409
+ } else {
410
+ cur_transform = opt_transform
411
+ raw = observed_raw
412
+ }
413
+
414
+ target_sample = rnorm(nrow(as.matrix(opt_samples ))) * sqrt(target_cov [i ,i ])
415
+
389
416
pivot = function (candidate ){
417
+
390
418
weights = importance_weight(noise_scale ,
391
419
t(as.matrix(target_sample ) + candidate ),
392
420
t(opt_samples ),
393
- opt_transform ,
421
+ cur_transform ,
394
422
target_transform ,
395
- observed_raw )
423
+ raw )
396
424
return (mean((target_sample + candidate < observed_target [i ]) * weights )/ mean(weights ))
425
+
397
426
}
427
+
398
428
rootU = function (candidate ){
399
429
return (pivot(observed_target [i ]+ candidate )- (1 - level )/ 2 )
400
430
}
431
+
401
432
rootL = function (candidate ){
402
- return (pivot(observed_target [i ]+ candidate )- (1 + level )/ 2 )
433
+ return (pivot(observed_target [i ]+ candidate )- (1 + level )/ 2 )
403
434
}
435
+
404
436
pvalues [i ] = pivot(0 )
405
- line_min = - 20 * sd(target_sample )
406
- line_max = 20 * sd(target_sample )
437
+ line_min = - 10 * sd(target_sample )
438
+ line_max = 10 * sd(target_sample )
439
+
407
440
if (rootU(line_min )* rootU(line_max )< 0 ){
408
441
ci [i ,2 ] = uniroot(rootU , c(line_min , line_max ))$ root + observed_target [i ]
409
442
} else {
0 commit comments