This function uses the degrees of freedom to calculate various information
criteria. This function uses the "unknown variance" version of the likelihood.
Only implemented for Gaussian regression. The constant is ignored (as in
stats::extractAIC()
).
Usage
estimate_risk(object, x, type = c("AIC", "BIC", "GCV"), approx_df = FALSE)
Arguments
- object
fitted object from a call to
sparsegl()
.- x
Matrix. The matrix of predictors used to estimate the
sparsegl
object. May be missing ifapprox_df = TRUE
.- type
one or more of AIC, BIC, or GCV.
- approx_df
the
df
component of asparsegl
object is an approximation (albeit a fairly accurate one) to the actual degrees-of-freedom. However, the exact value requires inverting a portion ofX'X
. So this computation may take some time (the default computes the exact df).
Value
a data.frame
with as many rows as object$lambda
. It contains
columns lambda
, df
, and the requested risk types.
References
Liang, X., Cohen, A., Sólon Heinsfeld, A., Pestilli, F., and
McDonald, D.J. 2024.
sparsegl: An R
Package for Estimating Sparse Group Lasso.
Journal of Statistical Software, Vol. 110(6): 1–23.
doi:10.18637/jss.v110.i06
.
Vaiter S, Deledalle C, Peyré G, Fadili J, Dossal C. (2012). The Degrees of Freedom of the Group Lasso for a General Design. https://arxiv.org/abs/1212.6478.
See also
sparsegl()
method.
Examples
n <- 100
p <- 20
X <- matrix(rnorm(n * p), nrow = n)
eps <- rnorm(n)
beta_star <- c(rep(5, 5), c(5, -5, 2, 0, 0), rep(-5, 5), rep(0, (p - 15)))
y <- X %*% beta_star + eps
groups <- rep(1:(p / 5), each = 5)
fit1 <- sparsegl(X, y, group = groups)
estimate_risk(fit1, type = "AIC", approx_df = TRUE)
#> lambda df AIC
#> s0 5.921308e-01 0.000000 5.62511380
#> s1 5.395275e-01 5.311419 5.72305786
#> s2 4.915974e-01 6.977741 5.67767125
#> s3 4.479252e-01 7.649619 5.62023813
#> s4 4.081328e-01 14.674902 5.64244754
#> s5 3.718754e-01 15.875112 5.52197579
#> s6 3.388390e-01 16.460216 5.39453962
#> s7 3.087375e-01 16.812670 5.26841723
#> s8 2.813101e-01 22.458141 5.20837399
#> s9 2.563193e-01 23.216783 5.04414653
#> s10 2.335486e-01 23.634093 4.87296726
#> s11 2.128008e-01 23.905164 4.69879650
#> s12 1.938961e-01 24.097675 4.52304107
#> s13 1.766709e-01 24.242154 4.34637371
#> s14 1.609760e-01 24.354717 4.16918975
#> s15 1.466753e-01 24.444809 3.99176406
#> s16 1.336451e-01 24.518397 3.81431716
#> s17 1.217724e-01 24.579466 3.63704779
#> s18 1.109545e-01 24.630794 3.46015131
#> s19 1.010976e-01 24.674385 3.28383160
#> s20 9.211637e-02 24.711726 3.10830980
#> s21 8.393300e-02 24.743949 2.93383129
#> s22 7.647663e-02 24.771927 2.76067182
#> s23 6.968265e-02 24.796349 2.58914288
#> s24 6.349224e-02 24.817767 2.41959642
#> s25 5.785176e-02 24.836626 2.25242871
#> s26 5.271237e-02 24.853291 2.08808274
#> s27 4.802955e-02 26.851382 1.96668124
#> s28 4.376274e-02 26.866232 1.80947420
#> s29 3.987498e-02 26.879453 1.65667494
#> s30 3.633259e-02 26.891250 1.50888978
#> s31 3.310491e-02 26.901798 1.36674130
#> s32 3.016396e-02 26.911246 1.23094486
#> s33 2.748427e-02 26.919724 1.10190415
#> s34 2.504265e-02 26.927341 0.98025729
#> s35 2.281793e-02 26.934194 0.86646922
#> s36 2.079085e-02 26.940367 0.76089872
#> s37 1.894384e-02 26.945934 0.66377750
#> s38 1.726093e-02 26.950958 0.57519562
#> s39 1.572751e-02 26.955497 0.49509586
#> s40 1.433032e-02 26.959601 0.42339832
#> s41 1.305726e-02 26.963314 0.35952238
#> s42 1.189729e-02 26.966675 0.30315924
#> s43 1.084036e-02 26.969720 0.25379056
#> s44 9.877336e-03 26.972480 0.21084082
#> s45 8.999861e-03 26.974982 0.17370599
#> s46 8.200338e-03 26.977252 0.14177739
#> s47 7.471843e-03 26.979313 0.11446127
#> s48 6.808065e-03 26.981183 0.09128276
#> s49 6.203255e-03 26.982881 0.07152875
#> s50 5.652175e-03 26.984425 0.05482024
#> s51 5.150051e-03 26.985827 0.04073024
#> s52 4.692535e-03 34.018902 0.16566601
#> s53 4.275663e-03 34.834162 0.16791184
#> s54 3.895825e-03 35.196135 0.16322204
#> s55 3.549731e-03 35.400385 0.15725964
#> s56 3.234382e-03 35.531086 0.15143058
#> s57 2.947049e-03 35.621573 0.14615812
#> s58 2.685241e-03 35.687686 0.14154877
#> s59 2.446692e-03 35.737915 0.13759186
#> s60 2.229334e-03 35.777221 0.13423252
#> s61 2.031286e-03 35.808521 0.13143672
#> s62 1.850832e-03 35.834226 0.12906154
#> s63 1.686410e-03 35.855516 0.12707643
#> s64 1.536594e-03 35.873363 0.12542459
#> s65 1.400087e-03 35.888478 0.12405420
#> s66 1.275707e-03 35.901393 0.12292026
#> s67 1.162377e-03 33.933588 0.08240652
#> s68 1.059114e-03 33.940875 0.08159125
#> s69 9.650256e-04 33.947227 0.08091957
#> s70 8.792954e-04 35.937855 0.12006794
#> s71 8.011812e-04 35.944284 0.11965737
#> s72 7.300065e-04 35.949927 0.11934121
#> s73 6.651547e-04 35.954983 0.11905780
#> s74 6.060642e-04 35.959483 0.11882344
#> s75 5.522231e-04 35.963492 0.11863281
#> s76 5.031651e-04 35.967068 0.11847895
#> s77 4.584653e-04 35.970265 0.11835551
#> s78 4.177365e-04 35.973128 0.11825707
#> s79 3.806260e-04 35.975696 0.11817907
#> s80 3.468122e-04 35.977966 0.11814228
#> s81 3.160024e-04 35.980072 0.11807347
#> s82 2.879296e-04 35.981920 0.11805185
#> s83 2.623507e-04 35.983602 0.11802603
#> s84 2.390442e-04 35.985125 0.11800391
#> s85 2.178082e-04 35.986503 0.11798665
#> s86 1.984587e-04 35.987749 0.11797385
#> s87 1.808282e-04 35.988877 0.11796484
#> s88 1.647639e-04 35.989897 0.11795893
#> s89 1.501267e-04 35.990822 0.11795549
#> s90 1.367899e-04 35.991659 0.11795400
#> s91 1.246378e-04 35.992419 0.11795403
#> s92 1.135654e-04 35.993107 0.11795520
#> s93 1.034765e-04 35.993732 0.11795722
#> s94 9.428396e-05 35.994299 0.11795987
#> s95 8.590803e-05 35.994814 0.11796294
#> s96 7.827620e-05 35.995282 0.11796630
#> s97 7.132236e-05 35.995707 0.11796982
#> s98 6.498628e-05 35.996093 0.11797341
#> s99 5.921308e-05 35.996445 0.11797699