Make predictions using the exclusive lasso. Similar to predict.glmnet. coef(...) is a wrapper around predict(..., type="coefficients").

# S3 method for ExclusiveLassoFit
coef(object, lambda = s, s = NULL, exact = FALSE, group_threshold = FALSE, ...)

# S3 method for ExclusiveLassoFit
predict(
  object,
  newx,
  lambda = s,
  s = NULL,
  type = c("link", "response", "coefficients"),
  group_threshold = FALSE,
  exact = FALSE,
  offset,
  ...
)

Arguments

object

An ExclusiveLassoFit object produced by exclusive_lasso.

lambda

The value of the regularization paramter (\(lambda\)) at which to return the fitted coefficients or predicted values. If not supplied, results for the entire regularization path are returned. Can be a vector.

s

An alternate argument that may be used to supply lambda. Included for compatability with glmnet.

exact

Should the exclusive lasso be re-run for provided values of lambda? If FALSE, approximate values obtained by linear interpolation on grid points are used instead. (Cf. the exact argument of predict.glmnet)

group_threshold

If TRUE, (hard-)threshold coefficients so that there is exactly one non-zero coefficient in each group.

...

Additional arguments passed to exclusive_lasso if exact=TRUE and ignored otherwise.

newx

New data \(X \in R^{m \times p}\) on which to make predictions. If not supplied, predictions are made on trainng data.

type

The type of "prediction" to return. If type="link", returns the linear predictor. If type="response", returns the expected value of the response. If type="coefficients", returns the coefficients used to calculate the linear predictor. (Cf. the type argument of predict.glmnet)

offset

An offset term used in predictions. If not supplied, all offets are taken to be zero. If the original fit was made with an offset, offset will be required.

Examples

n <- 200 p <- 500 groups <- rep(1:10, times=50) beta <- numeric(p); beta[1:10] <- 3 X <- matrix(rnorm(n * p), ncol=p) y <- X %*% beta + rnorm(n) exfit <- exclusive_lasso(X, y, groups) coef(exfit, lambda=1)
#> 501 x 1 sparse Matrix of class "dgCMatrix" #> #> (Intercept) -0.8556297 #> 1.6177055 #> 1.5167088 #> 1.5576356 #> 1.4557314 #> 1.3429220 #> 1.6525403 #> 1.4577423 #> 1.5505042 #> 1.6672350 #> 1.5469521 #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> . #> .
predict(exfit, lambda=1, newx = -X)
#> [,1] #> [1,] 0.47254886 #> [2,] 5.04540436 #> [3,] 3.85081483 #> [4,] 3.86975131 #> [5,] 3.41044951 #> [6,] -11.02415415 #> [7,] -3.64048632 #> [8,] 0.84734859 #> [9,] 0.91484137 #> [10,] -5.27402297 #> [11,] -0.39952876 #> [12,] 15.48880483 #> [13,] -4.44755518 #> [14,] -1.26347876 #> [15,] 8.95013545 #> [16,] 2.24589700 #> [17,] 1.99259187 #> [18,] -4.79237177 #> [19,] -15.13313313 #> [20,] -4.86348011 #> [21,] -4.37706904 #> [22,] 2.70501526 #> [23,] -6.09681031 #> [24,] 4.94912225 #> [25,] 2.44432918 #> [26,] 3.17673495 #> [27,] -2.86003757 #> [28,] 4.29162528 #> [29,] 0.32223678 #> [30,] 3.77050389 #> [31,] -6.66000532 #> [32,] 0.09047075 #> [33,] -0.99215098 #> [34,] 3.55388375 #> [35,] 4.19342872 #> [36,] 1.98284291 #> [37,] -2.34059964 #> [38,] -1.18307825 #> [39,] 8.61327266 #> [40,] 6.74050579 #> [41,] -0.33866601 #> [42,] -1.91875025 #> [43,] -1.31702917 #> [44,] 7.68592992 #> [45,] -1.64972236 #> [46,] -0.81285410 #> [47,] 6.43237118 #> [48,] -0.12193746 #> [49,] 1.89104319 #> [50,] -4.37134022 #> [51,] -2.67245892 #> [52,] 3.18941850 #> [53,] 2.18097264 #> [54,] 2.85382847 #> [55,] -6.63292420 #> [56,] 1.66931826 #> [57,] 1.63163890 #> [58,] -4.42714265 #> [59,] -4.44410912 #> [60,] 1.91851228 #> [61,] 2.39750877 #> [62,] 8.46343252 #> [63,] -9.54620712 #> [64,] 3.43543970 #> [65,] -3.22943907 #> [66,] -3.93991759 #> [67,] -1.66130886 #> [68,] -0.57741389 #> [69,] -6.09667523 #> [70,] -0.44403343 #> [71,] 4.64949698 #> [72,] 3.81658275 #> [73,] -8.19214944 #> [74,] -3.76640983 #> [75,] -0.20209651 #> [76,] -0.08813113 #> [77,] 1.52605165 #> [78,] 4.19690850 #> [79,] 9.11914243 #> [80,] 8.26153770 #> [81,] -12.94677573 #> [82,] 4.39251489 #> [83,] -1.29658645 #> [84,] -2.50812668 #> [85,] 2.35581350 #> [86,] -6.13685233 #> [87,] 6.60313314 #> [88,] -0.93794557 #> [89,] -0.43430395 #> [90,] -3.12316384 #> [91,] -2.83520741 #> [92,] 5.20006377 #> [93,] -0.37610596 #> [94,] -8.14300526 #> [95,] -8.49184170 #> [96,] -0.31911868 #> [97,] -10.87387683 #> [98,] 2.32531054 #> [99,] 1.13415970 #> [100,] 1.56365102 #> [101,] 2.80957222 #> [102,] -4.28933785 #> [103,] -0.09957953 #> [104,] -3.69449496 #> [105,] -2.73216312 #> [106,] 3.62273667 #> [107,] -1.00202528 #> [108,] 7.39108111 #> [109,] 3.48455726 #> [110,] 7.44041666 #> [111,] -8.31935266 #> [112,] 0.45002535 #> [113,] 4.55363791 #> [114,] 4.54573182 #> [115,] 2.78032953 #> [116,] 1.26106268 #> [117,] -3.54462755 #> [118,] -0.53023501 #> [119,] -3.24936429 #> [120,] -3.18899056 #> [121,] 5.38469234 #> [122,] 3.79904576 #> [123,] 6.27850271 #> [124,] -5.25953790 #> [125,] -2.66628451 #> [126,] 4.86876216 #> [127,] -5.99237063 #> [128,] 1.27887869 #> [129,] 0.42692097 #> [130,] -6.41946363 #> [131,] 2.14105757 #> [132,] -0.44362298 #> [133,] -4.23624492 #> [134,] -0.73645747 #> [135,] 6.22042585 #> [136,] 2.65659598 #> [137,] -7.07728521 #> [138,] 3.74924327 #> [139,] -2.20864705 #> [140,] -6.58030169 #> [141,] 5.58481826 #> [142,] 1.61568624 #> [143,] 2.36627809 #> [144,] -3.83065709 #> [145,] 1.21374710 #> [146,] -4.93889450 #> [147,] -5.39803234 #> [148,] -6.11532094 #> [149,] 2.75353808 #> [150,] 8.18100293 #> [151,] 0.29739668 #> [152,] -0.23586708 #> [153,] -5.43016288 #> [154,] -1.63182104 #> [155,] 9.23067617 #> [156,] -1.69699684 #> [157,] 12.75337736 #> [158,] 9.12022155 #> [159,] -5.88376162 #> [160,] 1.39665210 #> [161,] -1.83803987 #> [162,] 1.67764824 #> [163,] -9.79214240 #> [164,] 2.53719520 #> [165,] 0.42369412 #> [166,] -0.78505885 #> [167,] -0.23157177 #> [168,] 13.90286753 #> [169,] 11.03262775 #> [170,] -9.33342634 #> [171,] -5.90057250 #> [172,] 2.57447438 #> [173,] -10.45479716 #> [174,] -2.75092093 #> [175,] -5.42342954 #> [176,] -6.79782719 #> [177,] -3.01266611 #> [178,] -13.10772763 #> [179,] 1.12508714 #> [180,] 14.05695125 #> [181,] 1.10369774 #> [182,] 8.03950018 #> [183,] -2.90392063 #> [184,] -3.32725396 #> [185,] 5.01334697 #> [186,] 3.89815758 #> [187,] 1.42807095 #> [188,] -6.23357587 #> [189,] -1.15326796 #> [190,] -4.72568998 #> [191,] -0.47751063 #> [192,] -4.98765712 #> [193,] 6.90098602 #> [194,] 5.09570336 #> [195,] 6.74125193 #> [196,] -6.38915339 #> [197,] -5.44107262 #> [198,] 3.64343174 #> [199,] -1.84825908 #> [200,] 5.28245044