@@ -111,9 +111,13 @@ p is comparable to n. Ignored when n<p and set to TRUE.
111
111
112
112
\references {
113
113
114
+
114
115
Keli Liu , Jelena Markovic , Robert Tibshirani. More powerful post - selection
115
116
inference , with application to the Lasso. arXiv : 1801.09037
116
117
118
+ Tom Boot , Didier Nibbering. Inference in high - dimensional linear regression models.
119
+ arXiv : 1703.03282
120
+
117
121
}
118
122
\author {Jelena Markovic , Jonathan Taylor }
119
123
@@ -122,6 +126,7 @@ inference, with application to the Lasso. arXiv:1801.09037
122
126
library(selectiveInference )
123
127
library(glmnet )
124
128
set.seed(43 )
129
+
125
130
n = 200
126
131
p = 100
127
132
s = 2
@@ -153,5 +158,58 @@ out = ROSI(x,
153
158
dispersion = sigma ^ 2 )
154
159
out
155
160
161
+ # an alternate approximate inverse from Boot and Nibbering
162
+
163
+ out = ROSI(x ,
164
+ y ,
165
+ beta ,
166
+ lambda ,
167
+ dispersion = sigma ^ 2 ,
168
+ debiasing_method = " BN" )
169
+ out
170
+
171
+ # wide matrices work too
172
+
173
+ n = 100
174
+ p = 200
175
+ s = 2
176
+ sigma = 1
177
+
178
+ x = matrix (rnorm(n * p ),n ,p )
179
+ x = scale(x ,TRUE ,TRUE )
180
+
181
+ beta = c(rep(10 , s ), rep(0 ,p - s )) / sqrt(n )
182
+ y = x \%* \% beta + sigma * rnorm(n )
183
+
184
+ # first run glmnet
185
+ gfit = glmnet(x ,y ,standardize = FALSE )
186
+
187
+ # extract coef for a given lambda; note the 1/n factor!
188
+ # (and we don't save the intercept term)
189
+ lambda = 4 * sqrt(n )
190
+ lambda_glmnet = 4 / sqrt(n )
191
+ beta = selectiveInference ::: solve_problem_glmnet(x ,
192
+ y ,
193
+ lambda_glmnet ,
194
+ penalty_factor = rep(1 ,p ),
195
+ family = " gaussian" )
196
+ # compute fixed lambda p-values and selection intervals
197
+ out = ROSI(x ,
198
+ y ,
199
+ beta ,
200
+ lambda ,
201
+ dispersion = sigma ^ 2 )
202
+ out
203
+
204
+ # an alternate approximate inverse
205
+
206
+ out = ROSI(x ,
207
+ y ,
208
+ beta ,
209
+ lambda ,
210
+ dispersion = sigma ^ 2 ,
211
+ debiasing_method = " BN" )
212
+ out
213
+
156
214
}
157
215
0 commit comments