[d8e26d]: / SLEP_package_4.1 / SLEP / functions / invCov / sparseInverseCovariance.m

Download this file

99 lines (87 with data), 2.4 kB

 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
function Theta=sparseInverseCovariance(S, lambda, opts)
%
% Function sparseInverseCovariance
% sparse inverse covariance estimation
%
%% Problem
%
% max log( det( Theta ) ) - < S, Theta> - lambda * ||Theta||_1
%
%% Input parameters:
%
% S- Empirical covariance matrix
% lambda- regularization parameter
% opts- optional inputs
%
%% Output parameter:
% Theta- sparse inverse covariance
%
%% Copyright (C) 2009-2010 Jun Liu, and Jieping Ye
%
% You are suggested to first read the Manual.
%
% For any problem, please contact with Jun Liu via j.liu@asu.edu
%
% Composed on September 18, 2008.
%
%% Related papers
%
% The implementation is based on the following paper:
%
% [1] Jerome Friedman, Trevor Hastie, and Robert Tibshirani,
% Sparse inverse covariance estimation with the graphical lasso, 2007
%
% This function has been used in the following paper:
%
% [2] Shuai Huang, Jing Li, Liang Sun, Jun Liu, Teresa Wu,
% Kewei Chen, Adam Fleisher, Eric Reiman, and Jieping Ye,
% Learning Brain Connectivity of Alzheimer's Disease
% from Neuroimaging Data, NIPS, 2009
%
%% Related functions
%
% invCov.c
%
% Verify the number of input parameters
if (nargin <2)
error('\n Inputs: S and lambda should be specified!\n');
elseif (nargin==3)
opts=[];
end
if ~isfield(opts,'LassoMaxIter')
opts.LassoMaxIter=1000;
end
if ~isfield(opts,'fGap')
opts.fGap=1e-6;
end
if ~isfield(opts,'xGap')
opts.xGap=1e-4;
end
if ~isfield(opts,'maxIter')
opts.maxIter=1000;
end
if ~isfield(opts,'xtol')
opts.xtol=1e-4;
end
sum_S=sum(diag(S));
n=size(S,1);
% initialize Theta and a working variable W
Theta=zeros(n,n);
W=zeros(n,n);
% call the C function
invCov(Theta, W, S, lambda, sum_S, n, opts.LassoMaxIter, opts.fGap, opts.xGap, opts.maxIter, opts.xtol);
%% for the Lasso (by CD)
% LassoMaxIter:
% fGap
% xGap
% Note:
% the Lasso terminates either
% the change of the function value is less than fGap
% or the change of the solution in terms of L1 norm is less than xGap
% or the maximal iteration maxIter has achieved
%% for the outer loop
% maxIter
% xtol
% Note
% The outer loop terminates either the difference between ajacent solution in terms of L1 norm is less than xtol,
% or the maximal iterations has achieved