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
5331956
commit 5b3fd3c
Showing
7 changed files
with
464 additions
and
235 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,9 +1,9 @@ | ||
Package: glasso | ||
Title: Graphical lasso- estimation of Gaussian graphical models | ||
Version: 1.2 | ||
Version: 1.3 | ||
Author: Jerome Friedman, Trevor Hastie and Rob Tibshirani | ||
Description: Graphical lasso | ||
Maintainer: Rob Tibshirani <tibs@stat.stanford.edu> | ||
License: GPL-2 | ||
URL: http://www-stat.stanford.edu/~tibs/glasso | ||
Packaged: Wed Jun 18 23:50:37 2008; tibs | ||
Packaged: Thu Jan 8 07:40:34 2009; tibs |
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,2 +1,3 @@ | ||
export(glasso) | ||
export(glassopath) | ||
useDynLib(glasso) |
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 |
---|---|---|
|
@@ -35,7 +35,6 @@ if(start.type=="warm"){ | |
ww=w.init | ||
xx=wi.init | ||
} | ||
|
||
|
||
itrace=1*trace | ||
ipen=1*(penalize.diagonal) | ||
|
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,43 @@ | ||
glassopath=function (s, rholist=NULL, thr = 1e-04, maxit = 10000, approx = FALSE | ||
, | ||
penalize.diagonal = TRUE, w.init = NULL, | ||
wi.init = NULL, trace = FALSE) | ||
{ | ||
n = nrow(s) | ||
if(is.null(rholist)){ | ||
rholist=seq(max(abs(s))/10,max(abs(s)),length=10) | ||
} | ||
rholist=sort(rholist) | ||
itrace = 1 * trace | ||
ipen = 1 * (penalize.diagonal) | ||
ia = 1 * approx | ||
rho=xx=ww=matrix(0,n,n) | ||
nrho=length(rholist) | ||
beta=what=array(0,c(n,n,nrho)) | ||
jerrs=rep(0,nrho) | ||
mode(rholist) = "single" | ||
mode(nrho) = "integer" | ||
mode(rho) = "single" | ||
mode(s) = "single" | ||
mode(ww) = "single" | ||
mode(xx) = "single" | ||
mode(n) = "integer" | ||
mode(maxit) = "integer" | ||
mode(ia) = "integer" | ||
mode(itrace) = "integer" | ||
mode(ipen) = "integer" | ||
mode(thr) = "single" | ||
mode(beta) = "single" | ||
mode(what) = "single" | ||
mode(jerrs) = "integer" | ||
|
||
junk <- .Fortran("glassopath", beta=beta,what=what,jerrs=jerrs,rholist,nrho,n, s, rho, ia, itrace, ipen, | ||
thr, maxit = maxit, ww = ww, xx = xx, niter = integer(1), | ||
del = single(1), ierr = integer(1), PACKAGE="glasso") | ||
|
||
xx = array(junk$beta, c(n,n,nrho)) | ||
what = array(junk$what, c(n,n,nrho)) | ||
return(list(w=what, wi = xx, | ||
approx = approx, rholist=rholist, errflag = junk$jerrs)) | ||
} | ||
|
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,76 @@ | ||
\name{glassopath} | ||
\alias{glassopath} | ||
\title{Compute the Graphical lasso along a path} | ||
\description{ | ||
Estimates a sparse inverse covariance matrix using a lasso (L1) penalty, along a path | ||
of values for the regularization parameter | ||
} | ||
\usage{ | ||
glassopath(s, rholist=NULL, thr=1.0e-4, maxit=1e4, approx=FALSE, penalize.diagonal=TRUE, w.init=NULL,wi.init=NULL, trace=FALSE) | ||
} | ||
\arguments{ | ||
\item{s}{Covariance matrix:p by p matrix (symmetric)} | ||
\item{rholist}{Vector of non-negative regularization parameters for the lasso. | ||
Should be increasing from smallest to largest; actual path is computed from largest | ||
to smallest value of rho). | ||
If NULL, 10 values in a (hopefully reasonable) range are used. Note that | ||
the same parameter rholist[j] is used for all entries of the inverse covariance matrix; | ||
different penalties for different entries are not allowed. } | ||
\item{thr}{Threshold for convergence. Default value is 1e-4. Iterations stop when average absolute parameter change is less than thr * ave(abs(offdiag(s)))} | ||
\item{maxit}{Maximum number of iterations of outer loop. Default 10,000} | ||
\item{approx}{Approximation flag: if true, computes Meinhausen-Buhlmann(2006) | ||
approximation} | ||
\item{penalize.diagonal}{Should diagonal of inverse covariance be penalized? | ||
Dafault TRUE.} | ||
\item{w.init}{Optional starting values for estimated covariance matrix (p by p). | ||
Only needed when start="warm" is specified} | ||
\item{wi.init}{Optional starting values for estimated inverse covariance matrix (p by p) | ||
Only needed when start="warm" is specified} | ||
\item{trace}{Flag for printing out information as iterations proceed. | ||
Default FALSE} | ||
} | ||
|
||
\details{ | ||
Estimates a sparse inverse covariance matrix using a lasso (L1) penalty, along a path of | ||
regularization paramaters, | ||
using the approach of Friedman, Hastie and Tibshirani (2007). | ||
The Meinhausen-Buhlmann (2006) approximation is also implemented. | ||
The algorithm can also be used to estimate a graph with missing edges, | ||
by specifying which edges to omit in the zero argument, and setting rho=0. | ||
Or both fixed zeroes for some elements and regularization on the other elements | ||
can be specified. | ||
} | ||
\value{ | ||
A list with components | ||
\item{w}{Estimated covariance matrices, an array of dimension (nrow(s),ncol(n), length(rholist))} | ||
\item{wi}{Estimated inverse covariance matrix, an array of dimension (nrow(s),ncol(n), length(rholist))} | ||
\item{approx}{Value of input argument approx} | ||
\item{rholist}{Values of regularization parameter used} | ||
\item{errflag}{values of error flag (0 means no memory allocation error)} | ||
} | ||
|
||
|
||
\references{ | ||
Jerome Friedman, Trevor Hastie and Robert Tibshirani (2007). | ||
Sparse inverse covariance estimation with the lasso. | ||
Biostatistics 2007. http://www-stat.stanford.edu/~tibs/ftp/graph.pdf | ||
|
||
Meinshausen, N. and Buhlmann, P.(2006) | ||
High dimensional graphs | ||
and variable selection with the lasso. | ||
Annals of Statistics,34, p1436-1462. | ||
} | ||
\examples{ | ||
|
||
|
||
set.seed(100) | ||
|
||
x<-matrix(rnorm(50*20),ncol=20) | ||
s<- var(x) | ||
a<-glassopath(s) | ||
|
||
} | ||
\keyword{multivariate} | ||
\keyword{models} | ||
\keyword{graphs} | ||
|
Oops, something went wrong.