Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d772dcc
commit 189b3e9
Showing
21 changed files
with
1,114 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
Package: fastclime | ||
Type: Package | ||
Title: A Fast Solver for Parameterized Linear Programming Problems and | ||
Constrained L1 Minimization Approach to Sparse Precision Matrix | ||
Estimation | ||
Version: 1.2.5 | ||
Date: 2015-04-26 | ||
Title: A Fast Solver for Parameterized LP Problems, Constrained L1 | ||
Minimization Approach to Sparse Precision Matrix Estimation and | ||
Dantzig Selector | ||
Version: 1.4 | ||
Date: 2016-04-18 | ||
Author: Haotian Pang, Han Liu and Robert Vanderbei | ||
Maintainer: Haotian Pang <hpang@princeton.edu> | ||
Depends: R (>= 2.15.0), lattice, igraph, MASS, Matrix | ||
Description: An efficient method of recovering precision matrices | ||
by applying the parametric simplex method is provided in this package. | ||
The computation is based on a linear optimization solver. | ||
It also contains a generic Linear Programming solver and a | ||
parameterized Linear Programming solver based on the parametric simplex method. | ||
Description: Provides a method of recovering the precision matrix efficiently | ||
and solving for the dantzig selector by applying the parametric | ||
simplex method. The computation is based on a linear optimization | ||
solver. It also contains a generic LP solver and a parameterized LP | ||
solver using parametric simplex method. | ||
License: GPL-2 | ||
Repository: CRAN | ||
Packaged: 2015-04-28 15:09:28 UTC; Haotian | ||
Packaged: 2016-04-18 20:42:46 UTC; diqi | ||
NeedsCompilation: yes | ||
Date/Publication: 2015-04-29 01:00:45 | ||
Date/Publication: 2016-04-19 01:03:54 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#-------------------------------------------------------------------------------# | ||
# Package: fastclime # | ||
# dantzig(): Dantzig Selector Function # | ||
# Authors: Haotian Pang, Han Liu and Robert Vanderbei # | ||
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> # | ||
# Date: April 25th 2014 # | ||
# Version: 1.2.4 # | ||
#-------------------------------------------------------------------------------# | ||
dantzig <- function(X, y, lambda = 0.01, nlambda = 50) | ||
{ | ||
n0<-nrow(X) | ||
d0<-ncol(X) | ||
BETA0<-matrix(0,d0,nlambda) | ||
lambdalist<-matrix(0,nlambda,1) | ||
|
||
cat("compute X^TX and X^y \n") | ||
|
||
X2=t(X)%*%X | ||
Xy=t(X)%*%y | ||
|
||
cat("start recovering \n") | ||
|
||
# start.time <- Sys.time() | ||
str=.C("dantzig", as.double(X2), as.double(Xy), as.double(BETA0), | ||
as.integer(d0), as.double(lambda), as.integer(nlambda), as.double(lambdalist), PACKAGE="fastclime") | ||
# end.time <- Sys.time() | ||
# t0 <- end.time - start.time | ||
|
||
# ptm <- proc.time() | ||
# cat("prepare the solution path \n") | ||
# proc.time() - ptm | ||
# print(ptm) | ||
|
||
rm(X2,Xy) | ||
BETA0<-matrix(unlist(str[3]),d0,nlambda) | ||
lambdalist<-unlist(str[7]) | ||
|
||
validn<-sum(lambdalist>0) | ||
|
||
BETA0<-BETA0[,1:validn] | ||
|
||
final_lambda<-lambdalist[validn] | ||
cat("lambdamin is ", final_lambda,"\n") | ||
|
||
lambdalist<-lambdalist[1:validn] | ||
result<-list("X" = X, "y"=y, "BETA0"=BETA0, "n0"=n0, "d0"=d0, "validn"=validn, "lambdalist"=lambdalist) | ||
|
||
gc() | ||
class(result) = "dantzig" | ||
cat("Done! \n") | ||
|
||
return(result) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
#---------------------------------------------------------------------------------# | ||
# Package: fastclime # | ||
# Dantzig.generator: Generates sparse linear regression model for testing dantzig # | ||
# Authors: Haotian Pang, Han Liu, Robert Vanderbei and Di Qi # | ||
# Emails: <hpang@princeton.edu>, <hanliu@princeton.edu> and <rvdb@princetonedu> # | ||
# Date: April 17th 2016 # | ||
# Version: 1.4.2 # | ||
#---------------------------------------------------------------------------------# | ||
|
||
dantzig.generator <- function(n = 50, d = 100, sparsity = 0.1, sigma0=1) | ||
{ | ||
|
||
if(sparsity<1){ | ||
s<-floor(d*sparsity) | ||
} | ||
else{ | ||
s<-sparsity | ||
} | ||
|
||
|
||
BETA<-rep(0,d) | ||
pos<-rep(0,s) | ||
|
||
for (i in 1:s) | ||
{ | ||
|
||
a<-rnorm(1, mean=0, sd=1) | ||
si<-2*(rbinom(1,1,0.5)-0.5) | ||
n1<-floor(runif(1,min=1,max=d+1)) | ||
BETA[n1]=si*(1+a) | ||
pos[i]=n1 | ||
} | ||
|
||
sigma<-rnorm(n, mean=0, sd=sigma0) | ||
|
||
|
||
X0<-matrix(rnorm(n*d, mean = 0, sd = 1), n,d) | ||
y<-X0%*%BETA+sigma | ||
|
||
gc() | ||
|
||
sim = list(X0 = X0 , y = y, BETA=BETA, s=s, pos=pos) | ||
class(sim) = "sim" | ||
return(sim) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dantzig.selector <- function(lambdalist, BETA0, lambda){ | ||
for (i in 1:length(lambdalist)) { | ||
if (lambdalist[i] < lambda) { | ||
break; | ||
} | ||
} | ||
beta0<-BETA0[,i] | ||
return(beta0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
\name{dantzig} | ||
\alias{dantzig} | ||
|
||
\title{ | ||
A solver for the Dantzig selector estimator | ||
} | ||
|
||
\description{ | ||
Implementation of the Primal Dual (i.e. Self Dual) Simplex Method on Dantzig selector | ||
} | ||
|
||
\usage{ | ||
dantzig(X, y, lambda = 0.01, nlambda = 50) | ||
} | ||
|
||
\arguments{ | ||
\item{X}{ | ||
\code{x} is an \code{n} by \code{d} data matrix | ||
} | ||
\item{y}{ | ||
\code{y} is a length \code{n} response vector | ||
} | ||
\item{lambda}{ | ||
The parametric simplex method will stop when the calculated parameter is smaller than lambda. The default value is \code{0.01}. | ||
} | ||
\item{nlambda}{ | ||
This is the number of the maximum path length one would like to achieve. The default length is 50. | ||
} | ||
} | ||
|
||
\details{ | ||
This program applies the parametric simplex linear programming method to the Dantzig selector to solve for the regression coefficient vector. The solution path of the problem corresponds to the parameter in the parametric simplex method. | ||
} | ||
|
||
\note{ | ||
The program will stop when either the maximum number of iterations for each column \code{nlambda} is achieved or when the required \code{lambda} is achieved for each column. Note if d is large and nlambda is also large, it is possible that the program will fail to allocate memory for the path. | ||
} | ||
|
||
|
||
|
||
\value{ | ||
An object with S3 class \code{"dantzig"} is returned: | ||
\item{X}{ | ||
\code{X} is the \code{n} by \code{d} data matrix. | ||
} | ||
\item{y}{ | ||
\code{y} is a length \code{n} response vector. | ||
} | ||
\item{BETA0}{ | ||
\code{BETA0} is a \code{d} by \code{validn} matrix where each column has an estimated regression coefficient vector given a lambda interval. | ||
} | ||
|
||
\item{n0}{ | ||
\code{n0} is the number of rows in the \code{n} by \code{d} data matrix. | ||
} | ||
\item{d0}{ | ||
\code{d0} is the number of columns in the \code{n} by \code{d} data matrix. | ||
} | ||
\item{validn}{ | ||
\code{validn} is the number of solutions along the solution path. The maximum is \code{nlambda}. | ||
} | ||
\item{lambdalist}{ | ||
\code{lambdalist} is the decrementing path of the lambda solution values. | ||
} | ||
|
||
} | ||
|
||
\author{ | ||
Haotian Pang, Han Liu, Robert Vanderbei and Di Qi \cr | ||
Maintainer: Haotian Pang<hpang@princeton.edu> | ||
} | ||
|
||
\seealso{ | ||
\code{\link{dantzig.selector}} | ||
} | ||
|
||
\examples{ | ||
|
||
#generate data | ||
a = dantzig.generator(n = 200, d = 100, sparsity = 0.1) | ||
|
||
#regression coefficient estimation | ||
b = dantzig(a$X0, a$y, lambda = 0.1, nlambda = 100) | ||
|
||
} |
Oops, something went wrong.