lglasso

library(lglasso)

There are two main functions in this package. The first one is \(lglasso\) which can output a sparse network representing the precision matrix by maximizing the \(l_1\) penalized likelihood function. The second function if \(mle\), which can compute the maximum likelihood estimates of precision matrix and the correlation parameter \(\tau\) for a given network structure produced from function \(lglasso\).

##The sample data are subset of a larger longitudinal data set  from a clinical project. 
##There are 13 clusters  are involved in the sample data.
sample_data=lglasso:::sample_data
dim(sample_data)
#> [1] 100  22
sample_data[1:5,1:5]
#>   subject age Bifidobacterium Escherichia.Shigella Phocaeicola
#> 1     103  14      -2.7038308            -4.793854   -9.414017
#> 2     103  15      -0.4770604            -2.342624   -8.203014
#> 3     103  16       3.3974623             5.241120   -5.532109
#> 4     103  17      -1.5783620            -2.432638   -8.656051
#> 5     104   1      -5.8001556            -6.262590   -7.033613
#sample_data=as.matrix(sample_data)

Example 1: Heterogeneous model with dampening correlation.

a=lglasso(data = sample_data, rho = 0.7, heter=T, ty=2)
# Individual dampening rate:
round(a$tau,3)
#>  [1] 3.272 0.418 3.272 2.660 1.233 2.457 0.622 3.272 0.826 1.029 1.233 0.826
#> [13] 2.457

#  Number of edge in the estimated network: 
(length(which(a$omega!=0))-ncol(a$omega))/2
#> [1] 106
#  Subnetwork:

a$omega[1:5,1:5]
#>              [,1]        [,2]        [,3]        [,4]         [,5]
#> [1,]  0.168210106 -0.02328179  0.00000000 -0.05663374 -0.004241546
#> [2,] -0.023274705  0.13588280 -0.01162514  0.00000000 -0.023387341
#> [3,]  0.000000000 -0.01163005  0.13855159  0.00000000 -0.012298354
#> [4,] -0.056646205  0.00000000  0.00000000  0.23769213  0.000000000
#> [5,] -0.004263599 -0.02339186 -0.01229982  0.00000000  0.173754573
# loglikelihood: 

a$ll
#> [1] -2856.348

Example 2: Homogeneous model with dampening correlation.

b=lglasso(data = sample_data, rho = 0.7, heter=F,ty=2)
# Shared dampening rate
round(b$tau,3)
#> [1] 1.826
# Number of edge in the estimated network
(length(which(b$omega!=0))-ncol(b$omega))/2
#> [1] 107

# Subnetwork
b$omega[1:5,1:5]
#>              [,1]        [,2]         [,3]        [,4]         [,5]
#> [1,]  0.180419574 -0.02917221  0.000000000 -0.05672336 -0.007079478
#> [2,] -0.029167026  0.13966946 -0.013716293  0.00000000 -0.023584343
#> [3,]  0.000000000 -0.01372621  0.145078330  0.00000000 -0.008861326
#> [4,] -0.056729735  0.00000000  0.000000000  0.26418730  0.000000000
#> [5,] -0.007092007 -0.02358701 -0.008859485  0.00000000  0.176894920
# loglikelihood
b$ll
#> [1] -2841.08

Example 3: Heterogeneous model with uniform correlation.

c=lglasso(data = sample_data, rho = 0.7, heter=T, ty=0)

# indvidual dampening rate

round(c$tau,3)
#>  [1] 3.272 3.272 3.272 3.068 1.029 2.253 0.418 2.864 0.826 3.680 1.437 0.826
#> [13] 2.660

# Number of edge in the estimated network
(length(which(c$omega!=0))-ncol(c$omega))/2
#> [1] 119

# subnetwork
c$omega[1:5,1:5]
#>              [,1]        [,2]         [,3]        [,4]          [,5]
#> [1,]  0.137195407 -0.02263919  0.000000000 -0.05285821 -0.0045570955
#> [2,] -0.022638117  0.12906228 -0.013961526  0.00000000 -0.0205830624
#> [3,]  0.000000000 -0.01396010  0.111558902  0.00000000 -0.0004726525
#> [4,] -0.052857467  0.00000000  0.000000000  0.21813779  0.0000000000
#> [5,] -0.004554955 -0.02058416 -0.000472173  0.00000000  0.1373557823
# loglikelihood 
c$ll
#> [1] -2921.594

[1] Zhou, J., Gui, J., Viles, W.D., Chen, H., Madan, J.C., Coker, M.O., Hoen, A.G., 2021a. Identifying Microbial Interaction Networks Based on Irregularly Spaced Longitudinal 16S rRNA sequence data. https://doi.org/10.1101/2021.11.26.470159

[2] Friedman J., Hastie T., Tibshirani R. (2019) Graphical Lasso: Estimation of Gaussian Graphical Models, Version: 1.11. https://CRAN.R-project.org/package=glasso.