Skip to contents

Get the indices of nonzero coefficients from the pretrained models in a fitted ptLasso or cv.ptLasso object, excluding the intercept.

Usage

get.pretrain.support(
  fit,
  s = "lambda.min",
  gamma = "gamma.min",
  commonOnly = FALSE,
  includeOverall = TRUE,
  groups = 1:length(fit$fitind)
)

Arguments

fit

fitted "ptLasso" or "cv.ptLasso" object.

s

the choice of lambda to use. May be "lambda.min", "lambda.1se" or a numeric value. Default is "lambda.min".

gamma

for use only when 'relax = TRUE' was specified during training. The choice of 'gamma' to use. May be "gamma.min" or "gamma.1se". Default is "gamma.min".

commonOnly

whether to return the features that are chosen by more than half of the group- or response-specific models (TRUE) or the features that are chosen by any of the group-specific models (FALSE). Default is FALSE.

includeOverall

whether to return the features that are chosen by the overall model and not the group-specific models (TRUE) or the features that are chosen by the overall model or the group-specific models (FALSE). Default is TRUE. Not used when 'use.case = "timeSeries"'.

groups

which groups or responses to include when computing the support. Default is to include all groups/responses.

Value

If a ptLasso object is supplied, this returns a vector containing the indices of nonzero coefficients (excluding the intercept). If a cv.ptLasso object is supplied, this returns a list of results - one for each value of alpha.

See also

ptLasso, cv.ptLasso.

Author

Erin Craig and Rob Tibshirani
Maintainer: Erin Craig <erincr@stanford.edu>

Examples

# Train data
set.seed(1234)
out = gaussian.example.data()
x = out$x; y=out$y; groups = out$group;

fit = ptLasso(x, y, groups = groups, family = "gaussian", type.measure = "mse")

get.pretrain.support(fit) 
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  19  20  21
#> [20]  22  23  25  27  28  29  30  31  32  34  35  37  38  39  41  42  43  44  45
#> [39]  46  47  48  49  50  51  52  53  54  55  56  57  59  60  62  64  65  66  67
#> [58]  68  69  72  73  75  76  77  79  80  82  83  84  88  89  90  94  97  98  99
#> [77] 100 102 105 108 109 110 111 112 114 115 118 120

# only return features common to all groups 
get.pretrain.support(fit, commonOnly = TRUE) 
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 51 54 56 57 65 69 80 83 84 88

# group 1 only, don't include the overall model support
get.pretrain.support(fit, groups = 1, includeOverall = FALSE) 
#>  [1]   1   5  11  13  14  15  16  20  31  32  34  57  64  72  73  80  83  88  89
#> [20]  94 111 114

# group 1 only, include the overall model support
get.pretrain.support(fit, groups = 1, includeOverall = TRUE) 
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  20  31  32  34
#> [20]  54  56  57  64  69  72  73  80  83  84  88  89  94 111 114

cvfit = cv.ptLasso(x, y, groups = groups, family = "gaussian", type.measure = "mse")

get.pretrain.support(cvfit)
#> [[1]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  27  35  36  38  45  50  52  54
#> [20]  56  57  61  62  63  69  80  84  88 100
#> 
#> [[2]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  18  20  22
#> [20]  24  25  27  29  31  32  34  35  36  37  38  43  45  47  48  50  52  53  54
#> [39]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  72  73  75
#> [58]  80  83  84  88  89  90  91  93  94 100 103 106 108 111 113 114 115 117 118
#> [77] 119
#> 
#> [[3]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  21  22
#> [20]  23  25  27  29  30  31  32  34  35  36  37  38  43  45  46  47  48  50  51
#> [39]  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  69  70  72
#> [58]  73  75  80  82  83  84  88  89  91  94 100 103 106 108 110 111 113 114 115
#> [77] 117 119 120
#> 
#> [[4]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  21  22
#> [20]  23  27  29  30  31  32  34  35  36  37  38  41  42  43  45  46  47  48  49
#> [39]  50  51  52  53  54  55  56  57  60  61  62  63  64  65  66  67  69  72  73
#> [58]  75  79  80  83  84  88  89  90  91  94 100 106 108 109 110 111 114 115 117
#> [77] 119 120
#> 
#> [[5]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  20  21  22  23  25  27
#> [20]  29  30  32  35  36  37  38  41  42  43  45  46  47  48  49  50  51  52  53
#> [39]  54  55  56  57  59  60  61  62  63  65  69  75  79  80  82  83  84  88  90
#> [58] 100 105 108 110 120
#> 
#> [[6]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  20  21  22  23
#> [20]  25  27  29  30  31  32  34  35  36  37  38  41  42  43  45  46  47  48  49
#> [39]  50  51  52  53  54  55  56  57  59  60  61  62  63  64  65  66  69  72  73
#> [58]  75  76  77  79  80  83  84  88  89  90  94  99 100 108 109 110 111 112 114
#> [77] 117 118 120
#> 
#> [[7]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  21  22
#> [20]  23  25  27  28  29  30  31  32  34  35  36  37  38  39  40  41  42  43  44
#> [39]  45  46  47  48  49  50  51  52  53  54  55  56  57  59  60  61  62  63  64
#> [58]  65  66  67  68  69  72  73  75  76  77  79  80  82  83  84  88  89  90  91
#> [77]  93  94  98  99 100 102 105 108 109 110 111 112 113 114 115 117 118 119 120
#> 
#> [[8]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  18  19  20
#> [20]  21  22  23  25  27  28  29  30  31  32  34  35  36  37  38  39  40  41  42
#> [39]  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  59  60  61  62
#> [58]  63  64  65  66  67  68  69  72  73  75  76  77  79  80  82  83  84  88  89
#> [77]  90  93  94  98  99 100 102 105 108 109 110 111 112 113 114 115 118 120
#> 
#> [[9]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
#> [20]  20  21  22  23  25  27  28  29  30  32  35  36  37  38  39  40  41  42  43
#> [39]  44  45  46  47  48  49  50  51  52  53  54  55  56  57  59  60  61  62  63
#> [58]  64  65  66  67  68  69  72  73  75  76  77  79  80  82  83  84  88  89  90
#> [77]  93  94  98  99 100 102 105 108 109 110 111 112 115 118 120
#> 
#> [[10]]
#>   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
#>  [19]  19  20  21  22  23  25  27  28  29  30  31  32  34  35  36  37  38  39
#>  [37]  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57
#>  [55]  58  59  60  61  62  63  64  65  66  67  68  69  70  72  73  75  76  77
#>  [73]  78  79  80  82  83  84  87  88  89  90  91  92  93  94  95  97  98  99
#>  [91] 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 117 118
#> [109] 119 120
#> 
#> [[11]]
#>   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
#>  [19]  19  20  21  22  23  25  27  28  29  30  31  32  34  35  36  37  38  39
#>  [37]  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57
#>  [55]  58  59  60  61  62  63  64  65  66  67  68  69  70  72  73  75  76  77
#>  [73]  78  79  80  82  83  84  87  88  89  90  91  92  93  94  95  98  99 100
#>  [91] 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 117 118 119
#> [109] 120
#> 
get.pretrain.support(cvfit, groups = 1) 
#> [[1]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  27  35  36  38  45  50  52  54
#> [20]  56  57  61  62  63  69  80  84  88 100
#> 
#> [[2]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  18  20  22
#> [20]  24  25  27  29  31  32  34  35  36  37  38  43  45  47  48  50  52  54  56
#> [39]  57  58  59  60  61  62  63  64  65  66  67  68  69  70  72  73  75  80  83
#> [58]  84  88  89  90  91  93  94 100 103 106 108 111 113 114 115 117 118 119
#> 
#> [[3]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  22  27
#> [20]  29  31  32  34  35  36  37  38  43  45  47  50  52  54  56  57  58  59  60
#> [39]  61  62  63  64  65  66  67  69  70  72  73  75  80  83  84  88  89  91  94
#> [58] 100 103 106 108 111 113 114 115 117 119
#> 
#> [[4]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  27  31
#> [20]  32  34  35  36  37  38  45  50  52  54  56  57  60  61  62  63  64  66  67
#> [39]  69  72  73  80  83  84  88  89  91  94 100 106 108 111 114 115 117 119
#> 
#> [[5]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  27  35  36  38  45  50  52  54
#> [20]  56  57  61  62  63  69  80  84  88 100
#> 
#> [[6]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  20  27  31  32
#> [20]  34  35  36  37  38  45  50  52  54  56  57  61  62  63  64  66  69  72  73
#> [39]  80  83  84  88  89  94 100 108 111 114 117
#> 
#> [[7]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  18  20  27  29
#> [20]  31  32  34  35  36  37  38  45  50  52  54  56  57  60  61  62  63  64  66
#> [39]  67  69  72  73  80  83  84  88  89  91  93  94 100 108 111 113 114 115 117
#> [58] 119
#> 
#> [[8]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  20  27  31  32
#> [20]  34  35  36  38  45  50  52  54  56  57  61  62  63  64  66  69  72  73  80
#> [39]  83  84  88  89  94 100 111 113 114
#> 
#> [[9]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  13  14  15  16  20  27  35  36
#> [20]  38  45  50  52  54  56  57  61  62  63  69  80  83  84  88  89  94 100 111
#> 
#> [[10]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  18  20  22
#> [20]  27  29  31  32  34  35  36  37  38  43  45  47  48  50  52  54  56  57  58
#> [39]  59  60  61  62  63  64  65  66  67  69  70  72  73  75  77  79  80  83  84
#> [58]  88  89  90  91  93  94  95 100 101 103 104 106 108 111 113 114 115 117 118
#> [77] 119
#> 
#> [[11]]
#>  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  18  19  20
#> [20]  22  29  31  32  34  37  38  43  47  48  50  54  56  57  58  59  60  62  64
#> [39]  65  66  67  70  72  73  75  77  79  80  83  88  89  90  91  93  94  95 101
#> [58] 103 104 106 108 111 113 114 115 117 118 119
#>