picasso: PathwIse CAlibrated Sparse Shooting algOrithm (PICASSO)

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/picasso.R

Description

The function "picasso" implements the user interface.

Usage

1
2
3
4
5
picasso(X, Y, lambda = NULL, nlambda = 100, lambda.min.ratio =
                 0.05, family = "gaussian", method = "l1",
                 type.gaussian = "naive", gamma = 3, df = NULL,
                 standardize = TRUE, intercept = TRUE, prec = 1e-07,
                 max.ite = 1000, verbose = FALSE)

Arguments

X

X is an n by d design matrix where n is the sample size and d is the data dimension.

Y

Y is the n dimensional response vector. Y is numeric vector for family=``gaussian'' and family=``sqrtlasso'', or a two-level factor for family=``binomial'', or a non-negative integer vector representing counts for family = ``gaussian''.

lambda

A sequence of decresing positive values to control the regularization. Typical usage is to leave the input lambda = NULL and have the program compute its own lambda sequence based on nlambda and lambda.min.ratio. Users can also specify a sequence to override this. Default value is from lambda.max to lambda.min.ratio*lambda.max. The default value of lambda.max is the minimum regularization parameter which yields an all-zero estimates.

nlambda

The number of values used in lambda. Default value is 100.

lambda.min.ratio

The smallest value for lambda, as a fraction of the uppperbound (MAX) of the regularization parameter. The program can automatically generate lambda as a sequence of length = nlambda starting from MAX to lambda.min.ratio*MAX in log scale. The default value is 0.05.

Caution: logistic and poisson regression can be ill-conditioned if lambda is too small for nonconvex penalty. We suggest the user to avoid using any lambda.min.raito smaller than 0.05 for logistic/poisson regression under nonconvex penalty.

family

Options for model. Sparse linear regression and sparse multivariate regression is applied if family = "gaussian", sqrt lasso is applied if family = "sqrtlasso", sparse logistic regression is applied if family = "binomial" and sparse poisson regression is applied if family = "poisson". The default value is "gaussian".

method

Options for regularization. Lasso is applied if method = "l1", MCP is applied if method = "mcp" and SCAD Lasso is applied if method = "scad". The default value is "l1".

type.gaussian

Options for updating residuals in sparse linear regression. The naive update rule is applied if opt = "naive", and the covariance update rule is applied if opt = "covariance". The default value is "naive".

gamma

The concavity parameter for MCP and SCAD. The default value is 3.

df

Maximum degree of freedom for the covariance update. The default value is 2*n.

standardize

Design matrix X will be standardized to have mean zero and unit standard deviation if standardize = TRUE. The default value is TRUE.

intercept

Does the model has intercept term or not. Default value is TRUE.

prec

Stopping precision. The default value is 1e-7.

max.ite

Max number of iterations for the algorithm. The default value is 1000.

verbose

Tracing information is disabled if verbose = FALSE. The default value is FALSE.

Details

For sparse linear regression,

\min_{β} {\frac{1}{2n}}|| Y - X β - β_0||_2^2 + λ R(β),


where R(β) can be \ell_1 norm, MCP, SCAD regularizers.

For sparse logistic regression,

\min_{β} {\frac{1}{n}}∑_{i=1}^n (\log(1+e^{x_i^T β+ β_0}) - y_i x_i^T β) + λ R(β),


where R(β) can be \ell_1 norm, MCP, and SCAD regularizers.

For sparse poisson regression,

\min_{β} {\frac{1}{n}}∑_{i=1}^n (e^{x_i^T β + β_0} - y_i (x_i^T β+β_0) + λ R(β),


where R(β) can be \ell_1 norm, MCP or SCAD regularizers.

Value

An object with S3 classes "gaussian", "binomial", and "poisson" corresponding to sparse linear regression, sparse logistic regression, and sparse poisson regression respectively is returned:

beta

A matrix of regression estimates whose columns correspond to regularization parameters for sparse linear regression and sparse logistic regression. A list of matrices of regression estimation corresponding to regularization parameters for sparse column inverse operator.

intercept

The value of intercepts corresponding to regularization parameters for sparse linear regression, and sparse logistic regression.

Y

The value of Y used in the program.

X

The value of X used in the program.

lambda

The sequence of regularization parameters lambda used in the program.

nlambda

The number of values used in lambda.

family

The family from the input.

method

The method from the input.

path

A list of d by d adjacency matrices of estimated graphs as a graph path corresponding to lambda.

sparsity

The sparsity levels of the graph path for sparse inverse column operator.

standardize

The standardize from the input.

df

The degree of freecom (number of nonzero coefficients) along the solution path for sparse linear regression, nd sparse logistic regression.

ite

A list of vectors where the i-th entries of ite[[1]] and ite[[2]] correspond to the outer iteration and inner iteration of i-th regularization parameter respectively.

verbose

The verbose from the input.

Author(s)

Jason Ge, Xingguo Li, Mengdi Wang, Tong Zhang, Han Liu and Tuo Zhao
Maintainer: Jason Ge <jiange@princeton.edu>

References

1. J. Friedman, T. Hastie and H. Hofling and R. Tibshirani. Pathwise coordinate optimization. The Annals of Applied Statistics, 2007.
2. C.H. Zhang. Nearly unbiased variable selection under minimax concave penalty. Annals of Statistics, 2010.
3. J. Fan and R. Li. Variable selection via nonconcave penalized likelihood and its oracle properties. Journal of the American Statistical Association, 2001.
4. R. Tibshirani, J. Bien, J. Friedman, T. Hastie, N. Simon, J. Taylor and R. Tibshirani. Strong rules for discarding predictors in lasso-type problems. Journal of the Royal Statistical Society: Series B, 2012.
5. T. Zhao, H. Liu, and T. Zhang. A General Theory of Pathwise Coordinate Optimization. Techinical Report, Princeton Univeristy.

See Also

picasso-package.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
################################################################
## Sparse linear regression
## Generate the design matrix and regression coefficient vector
n = 100 # sample number 
d = 80 # sample dimension
c = 0.5 # correlation parameter
s = 20  # support size of coefficient
set.seed(2016)
X = scale(matrix(rnorm(n*d),n,d)+c*rnorm(n))/sqrt(n-1)*sqrt(n)
beta = c(runif(s), rep(0, d-s))

## Generate response using Gaussian noise, and fit sparse linear models
noise = rnorm(n)
Y = X%*%beta + noise

## l1 regularization solved with naive update
fitted.l1.naive = picasso(X, Y, nlambda=100, type.gaussian="naive")

## l1 regularization solved with covariance update
fitted.l1.covariance  = picasso(X, Y, nlambda=100, type.gaussian="covariance")

## mcp regularization
fitted.mcp = picasso(X, Y, nlambda=100, method="mcp")

## scad regularization
fitted.scad = picasso(X, Y, nlambda=100, method="scad")

## lambdas used 
print(fitted.l1.naive$lambda)

## number of nonzero coefficients for each lambda
print(fitted.l1.naive$df)

## coefficients and intercept for the i-th lambda
i = 30
print(fitted.l1.naive$lambda[i])
print(fitted.l1.naive$beta[,i])
print(fitted.l1.naive$intercept[i])

## Visualize the solution path
plot(fitted.l1.naive)
plot(fitted.l1.covariance)
plot(fitted.mcp)
plot(fitted.scad)


################################################################
## Sparse logistic regression
## Generate the design matrix and regression coefficient vector
n <- 100  # sample number 
d <- 80   # sample dimension
c <- 0.5   # parameter controlling the correlation between columns of X
s <- 20    # support size of coefficient
set.seed(2016)
X <- scale(matrix(rnorm(n*d),n,d)+c*rnorm(n))/sqrt(n-1)*sqrt(n)
beta <- c(runif(s), rep(0, d-s))

## Generate response and fit sparse logistic models
p = 1/(1+exp(-X%*%beta))
Y = rbinom(n, rep(1,n), p)

## l1 regularization
fitted.l1 = picasso(X, Y, nlambda=100, family="binomial", method="l1")

## mcp regularization
fitted.mcp = picasso(X, Y, nlambda=100, family="binomial", method="mcp")

## scad regularization
fitted.scad = picasso(X, Y, nlambda=100, family="binomial", method="scad")

## lambdas used 
print(fitted.l1$lambda)

## number of nonzero coefficients for each lambda
print(fitted.l1$df)

## coefficients and intercept for the i-th lambda
i = 30
print(fitted.l1$lambda[i])
print(fitted.l1$beta[,i])
print(fitted.l1$intercept[i])

## Visualize the solution path
plot(fitted.l1)

## Estimate of Bernoulli parameters
param.l1 = fitted.l1$p


################################################################
## Sparse poisson regression
## Generate the design matrix and regression coefficient vector
n <- 100  # sample number 
d <- 80   # sample dimension
c <- 0.5   # parameter controlling the correlation between columns of X
s <- 20    # support size of coefficient
set.seed(2016)
X <- scale(matrix(rnorm(n*d),n,d)+c*rnorm(n))/sqrt(n-1)*sqrt(n)
beta <- c(runif(s), rep(0, d-s))/sqrt(s)

## Generate response and fit sparse poisson models
p = X%*%beta+rnorm(n)
Y = rpois(n, exp(p))

## l1 regularization
fitted.l1 = picasso(X, Y, nlambda=100, family="poisson", method="l1")

## mcp regularization
fitted.mcp = picasso(X, Y, nlambda=100, family="poisson", method="mcp")

## scad regularization
fitted.scad = picasso(X, Y, nlambda=100, family="poisson", method="scad")

## lambdas used 
print(fitted.l1$lambda)

## number of nonzero coefficients for each lambda
print(fitted.l1$df)

## coefficients and intercept for the i-th lambda
i = 30
print(fitted.l1$lambda[i])
print(fitted.l1$beta[,i])
print(fitted.l1$intercept[i])

## Visualize the solution path
plot(fitted.l1)

Example output

Loading required package: MASS
Loading required package: Matrix
  [1] 2.6962716 2.6159047 2.5379333 2.4622859 2.3888934 2.3176884 2.2486058
  [8] 2.1815823 2.1165566 2.0534691 1.9922620 1.9328793 1.8752666 1.8193712
 [15] 1.7651418 1.7125288 1.6614840 1.6119607 1.5639135 1.5172984 1.4720728
 [22] 1.4281952 1.3856255 1.3443246 1.3042547 1.2653792 1.2276625 1.1910699
 [29] 1.1555681 1.1211245 1.0877075 1.0552865 1.0238320 0.9933149 0.9637075
 [36] 0.9349826 0.9071139 0.8800758 0.8538437 0.8283935 0.8037018 0.7797461
 [43] 0.7565045 0.7339556 0.7120788 0.6908541 0.6702621 0.6502838 0.6309010
 [50] 0.6120959 0.5938514 0.5761507 0.5589775 0.5423163 0.5261516 0.5104688
 [57] 0.4952534 0.4804915 0.4661697 0.4522747 0.4387939 0.4257149 0.4130258
 [64] 0.4007149 0.3887709 0.3771829 0.3659404 0.3550329 0.3444505 0.3341836
 [71] 0.3242227 0.3145587 0.3051828 0.2960863 0.2872609 0.2786986 0.2703916
 [78] 0.2623321 0.2545128 0.2469267 0.2395666 0.2324259 0.2254981 0.2187767
 [85] 0.2122557 0.2059291 0.1997910 0.1938359 0.1880583 0.1824529 0.1770146
 [92] 0.1717384 0.1666194 0.1616531 0.1568347 0.1521600 0.1476246 0.1432244
 [99] 0.1389554 0.1348136
  [1]  0  2  2  2  3  3  3  3  4  5  6  7  8  8  8  8 10 10 10 10 10 11 11 13 13
 [26] 13 14 15 15 15 15 15 15 15 15 15 16 16 16 16 17 17 18 18 18 18 18 18 18 19
 [51] 19 20 20 20 20 20 20 21 22 23 24 24 24 24 24 24 24 24 25 25 25 25 25 27 27
 [76] 28 28 27 27 27 27 27 28 28 28 29 29 29 29 30 30 30 30 30 30 30 30 30 30 30
[1] 1.121124
 [1] 0.00000000 0.39041935 0.00000000 0.82043000 0.76373155 0.00000000
 [7] 0.00000000 0.00000000 0.03667189 0.00000000 0.32238499 0.30002355
[13] 0.00000000 0.00000000 0.16732789 0.00000000 0.00000000 0.07530103
[19] 0.17252385 0.67122860 0.00000000 0.00000000 0.00000000 0.00000000
[25] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[31] 0.00000000 0.00000000 0.02951707 0.00000000 0.00000000 0.01913015
[37] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[43] 0.00000000 0.00000000 0.00000000 0.19734050 0.00000000 0.00000000
[49] 0.00000000 0.00000000 0.14060015 0.00000000 0.00000000 0.00000000
[55] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[61] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[67] 0.10066723 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[73] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[79] 0.00000000 0.00000000
[1] -0.1021742
  [1] 0.27262689 0.26450079 0.25661690 0.24896800 0.24154710 0.23434738
  [7] 0.22736226 0.22058535 0.21401044 0.20763150 0.20144269 0.19543836
 [13] 0.18961299 0.18396126 0.17847798 0.17315815 0.16799688 0.16298945
 [19] 0.15813128 0.15341791 0.14884503 0.14440846 0.14010412 0.13592808
 [25] 0.13187652 0.12794572 0.12413208 0.12043212 0.11684244 0.11335975
 [31] 0.10998088 0.10670271 0.10352226 0.10043660 0.09744292 0.09453847
 [37] 0.09172060 0.08898671 0.08633431 0.08376097 0.08126434 0.07884212
 [43] 0.07649210 0.07421212 0.07200011 0.06985402 0.06777191 0.06575185
 [49] 0.06379201 0.06189058 0.06004583 0.05825606 0.05651964 0.05483498
 [55] 0.05320053 0.05161480 0.05007633 0.04858373 0.04713561 0.04573065
 [61] 0.04436757 0.04304512 0.04176209 0.04051730 0.03930962 0.03813793
 [67] 0.03700116 0.03589828 0.03482827 0.03379016 0.03278298 0.03180583
 [73] 0.03085781 0.02993804 0.02904568 0.02817993 0.02733998 0.02652507
 [79] 0.02573444 0.02496738 0.02422319 0.02350118 0.02280068 0.02212107
 [85] 0.02146172 0.02082201 0.02020138 0.01959924 0.01901505 0.01844828
 [91] 0.01789840 0.01736491 0.01684732 0.01634515 0.01585796 0.01538529
 [97] 0.01492670 0.01448179 0.01405013 0.01363134
  [1]  0  1  2  2  2  2  3  4  4  4  5  5  5  6  6  6  6  6  6 10 10 10 11 11 12
 [26] 12 12 13 14 14 14 14 14 14 16 16 16 17 17 17 17 17 17 17 17 17 17 17 17 18
 [51] 19 19 19 19 19 19 19 19 19 19 19 19 19 20 20 20 20 20 19 19 19 19 19 19 19
 [76] 19 20 21 21 21 21 21 21 21 22 22 22 22 22 22 22 23 23 23 24 25 25 25 25 27
[1] 0.1133598
 [1] 0.00000000 0.10244270 0.00000000 0.46128249 0.18194580 0.00000000
 [7] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.22600408
[13] 0.15755685 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[19] 0.07763224 0.03719967 0.00000000 0.00000000 0.00000000 0.00000000
[25] 0.18445428 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[31] 0.00000000 0.00000000 0.00000000 0.01984117 0.02024449 0.00000000
[37] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[43] 0.00000000 0.00000000 0.00000000 0.23618903 0.00000000 0.00000000
[49] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[55] 0.00000000 0.00000000 0.00000000 0.00000000 0.03589676 0.00000000
[61] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[67] 0.00000000 0.03289810 0.00000000 0.00000000 0.00000000 0.00000000
[73] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
[79] 0.01038179 0.00000000
[1] 0.04240205
  [1] 2.0366819 1.9759752 1.9170779 1.8599362 1.8044977 1.7507116 1.6985287
  [8] 1.6479012 1.5987828 1.5511284 1.5048944 1.4600385 1.4165196 1.3742979
 [15] 1.3333346 1.2935924 1.2550347 1.2176263 1.1813329 1.1461213 1.1119592
 [22] 1.0788154 1.0466595 1.0154621 0.9851945 0.9558292 0.9273391 0.8996982
 [29] 0.8728812 0.8468635 0.8216213 0.7971315 0.7733717 0.7503200 0.7279555
 [36] 0.7062575 0.6852064 0.6647826 0.6449677 0.6257433 0.6070920 0.5889966
 [43] 0.5714406 0.5544078 0.5378828 0.5218503 0.5062957 0.4912047 0.4765635
 [50] 0.4623587 0.4485774 0.4352068 0.4222347 0.4096493 0.3974390 0.3855927
 [57] 0.3740994 0.3629488 0.3521305 0.3416346 0.3314516 0.3215722 0.3119872
 [64] 0.3026879 0.2936658 0.2849126 0.2764203 0.2681811 0.2601875 0.2524322
 [71] 0.2449080 0.2376081 0.2305258 0.2236546 0.2169882 0.2105205 0.2042456
 [78] 0.1981577 0.1922513 0.1865209 0.1809614 0.1755675 0.1703344 0.1652573
 [85] 0.1603315 0.1555526 0.1509161 0.1464178 0.1420536 0.1378194 0.1337115
 [92] 0.1297260 0.1258593 0.1221078 0.1184682 0.1149371 0.1115112 0.1081874
 [99] 0.1049627 0.1018341
  [1]  1  1  1  1  1  1  1  1  1  2  2  3  4  4  5  5  5  5  5  5  6  6  6  6  6
 [26]  6  7  7  7  7  7  7  8  8  9  9  9 12 13 13 13 13 13 13 13 13 13 13 13 13
 [51] 13 13 13 14 14 15 16 16 16 17 17 19 19 19 20 20 21 21 21 21 20 22 23 24 25
 [76] 26 26 26 26 26 26 29 30 30 30 31 31 32 32 32 33 33 33 33 33 32 33 33 33 34
[1] 0.8468635
 [1] 0.000000000 0.000000000 0.000000000 0.000000000 0.058049503 0.000000000
 [7] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[13] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[19] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[25] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.007511794
[31] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[37] 0.000000000 0.058984766 0.000000000 0.000000000 0.000000000 0.000000000
[43] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[49] 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[55] 0.000000000 0.000000000 0.000000000 0.124873262 0.000000000 0.000000000
[61] 0.000000000 0.000000000 0.000000000 0.114558687 0.000000000 0.000000000
[67] 0.000000000 0.000000000 0.000000000 0.112324156 0.000000000 0.000000000
[73] 0.347504551 0.000000000 0.000000000 0.000000000 0.000000000 0.000000000
[79] 0.000000000 0.000000000
[1] 0.6004264

picasso documentation built on May 1, 2019, 6:28 p.m.