Skip to content

Commit b127083

Browse files
added an argument to limit the number of times the linesearch runs
1 parent 93a9602 commit b127083

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

selectiveInference/R/funs.fixed.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# min 1/2 || y - \beta_0 - X \beta ||_2^2 + \lambda || \beta ||_1
44

55
fixedLassoInf <- function(x, y, beta, lambda, family=c("gaussian","binomial","cox"),intercept=TRUE, add.targets=NULL, status=NULL,
6-
sigma=NULL, alpha=0.1,
7-
type=c("partial","full"), tol.beta=1e-5, tol.kkt=0.1,
8-
gridrange=c(-100,100), bits=NULL, verbose=FALSE) {
6+
sigma=NULL, alpha=0.1,
7+
type=c("partial","full"), tol.beta=1e-5, tol.kkt=0.1,
8+
gridrange=c(-100,100), bits=NULL, verbose=FALSE, linesearch.try=5) {
99

1010
family = match.arg(family)
1111
this.call = match.call()
@@ -158,7 +158,7 @@ sigma=NULL, alpha=0.1,
158158

159159
# Approximate inverse covariance matrix for when (n < p) from lasso_Inference.R
160160

161-
htheta <- InverseLinfty(hsigma, n, length(S), verbose=FALSE)
161+
htheta <- InverseLinfty(hsigma, n, length(S), verbose=FALSE, max.try=linesearch.try)
162162
# htheta <- InverseLinfty(hsigma, n, verbose=FALSE)
163163

164164
FS = rbind(diag(length(S)),matrix(0,pp-length(S),length(S)))
@@ -268,7 +268,7 @@ fixedLasso.poly=
268268
### Functions borrowed and slightly modified from lasso_inference.R
269269

270270
## Approximates inverse covariance matrix theta
271-
InverseLinfty <- function(sigma, n, e, resol=1.2, mu=NULL, maxiter=50, threshold=1e-2, verbose = TRUE) {
271+
InverseLinfty <- function(sigma, n, e, resol=1.2, mu=NULL, maxiter=50, threshold=1e-2, verbose = TRUE, max.try=10) {
272272
isgiven <- 1;
273273
if (is.null(mu)){
274274
isgiven <- 0;
@@ -293,13 +293,12 @@ InverseLinfty <- function(sigma, n, e, resol=1.2, mu=NULL, maxiter=50, threshold
293293

294294
output = NULL
295295

296-
while ((mu.stop != 1)&&(try.no<10)){
296+
while ((mu.stop != 1) && (try.no<max.try) ){
297297
last.beta <- beta
298-
#print(c("#######################trying ", try.no))
299298
output <- InverseLinftyOneRow(sigma, i, mu, maxiter=maxiter, soln_result=output) # uses a warm start
300299
beta <- output$soln
301300
iter <- output$iter
302-
if (isgiven==1){
301+
if (isgiven==1) {
303302
mu.stop <- 1
304303
}
305304
else{

selectiveInference/man/fixedLassoInf.Rd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ fixed value of the tuning parameter lambda
1010
}
1111
\usage{
1212
fixedLassoInf(x, y, beta, lambda, family = c("gaussian", "binomial",
13-
"cox"),intercept=TRUE, add.targets=NULL, status=NULL, sigma=NULL, alpha=0.1,
13+
"cox"),intercept=TRUE, add.targets=NULL, status=NULL, sigma=NULL, alpha=0.1,
1414
type=c("partial","full"), tol.beta=1e-5, tol.kkt=0.1,
15-
gridrange=c(-100,100), bits=NULL, verbose=FALSE)
15+
gridrange=c(-100,100), bits=NULL, verbose=FALSE, linesearch.try=5)
1616
}
1717
\arguments{
1818
\item{x}{
@@ -85,7 +85,11 @@ helpful (though computationally more costly). In particular, extra precision mig
8585
if the values in the output columns of \code{tailarea} differ noticeably from alpha/2.
8686
}
8787
\item{verbose}{
88-
Print out progress along the way? Default is FALSE}
88+
Print out progress along the way? Default is FALSE
89+
}
90+
\item{linesearch.try}{
91+
When running type="full" (i.e. debiased LASSO) how many attempts in the line search?
92+
}
8993
}
9094
9195
\details{

selectiveInference/src/Rcpp-debias.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include <Rcpp.h> // need to include the main Rcpp header file
22
#include <debias.h> // where find_one_row_void is defined
33

4+
// Below, the gradient should be equal to Sigma * theta + linear_func!!
5+
// No check is done on this.
6+
47
// [[Rcpp::export]]
58
Rcpp::List solve_QP(Rcpp::NumericMatrix Sigma,
69
double bound,

0 commit comments

Comments
 (0)