@@ -145,7 +145,7 @@ p = 10
145
145
sigma = 1
146
146
147
147
x = matrix(rnorm(n*p),n,p)
148
- x= scale(x,TRUE,TRUE)
148
+ x = scale(x,TRUE,TRUE)
149
149
150
150
beta = c(3,2,rep(0,p-2))
151
151
y = x\% *\% beta + sigma*rnorm(n)
@@ -165,10 +165,10 @@ out
165
165
166
166
# # as above, but use lar function instead to get initial
167
167
# # lasso fit (should get same results)
168
- lfit = lar(x ,y ,normalize = FALSE )
169
- beta = coef(lfit ,s = lambda ,mode = " lambda" )
170
- out2 = fixedLassoInf(x ,y ,beta ,lambda ,sigma = sigma )
171
- out2
168
+ lfit = lar(x ,y ,normalize = FALSE )
169
+ beta = coef(lfit ,s = lambda ,mode = " lambda" )
170
+ out2 = fixedLassoInf(x ,y ,beta ,lambda ,sigma = sigma )
171
+ out2
172
172
173
173
# # mimic different penalty factors by first scaling x
174
174
set.seed(43 )
@@ -249,5 +249,30 @@ status=sample(c(0,1),size=n,replace=TRUE)
249
249
# compute fixed lambda p-values and selection intervals
250
250
out = fixedLassoInf(x ,tim ,beta_hat ,lambda ,status = status ,family = " cox" )
251
251
out
252
+
253
+ # Debiased lasso or "full"
254
+
255
+ n = 50
256
+ p = 100
257
+ sigma = 1
258
+
259
+ x = matrix (rnorm(n * p ),n ,p )
260
+ x = scale(x ,TRUE ,TRUE )
261
+
262
+ beta = c(3 ,2 ,rep(0 ,p - 2 ))
263
+ y = x \%* \%beta + sigma * rnorm(n )
264
+
265
+ # first run glmnet
266
+ gfit = glmnet(x , y , standardize = FALSE , intercept = FALSE )
267
+
268
+ # extract coef for a given lambda; note the 1/n factor!
269
+ # (and we don't save the intercept term)
270
+ lambda = 2.8
271
+ beta = coef(gfit , s = lambda / n , exact = TRUE )[- 1 ]
272
+
273
+ # compute fixed lambda p-values and selection intervals
274
+ out = fixedLassoInf(x , y , beta , lambda , sigma = sigma , type = ' full' , intercept = FALSE )
275
+ out
276
+
252
277
}
253
278
0 commit comments