| Title: | Graphical Lasso for Longitudinal Data |
|---|---|
| Description: | Estimate treatment-specific precision matrices (networks) from longitudinal high-dimensional normal data. The corresponding random effects are also estimated. It is motivated by the analysis of omics data in clinical trials where the longitudinal omics data becomes increasingly common. It includes both one-stage models (without treatment) and two-stage models (with one treatment). For details of the algorithms, please check the materials on its GitHub repo. If you have any questions, feel free to contact the maintainers through the email below. |
| Authors: | Jie Zhou [aut, cre, cph], Jiang Gui [aut], Weston Viles [aut], Anne Hoen [aut] |
| Maintainer: | Jie Zhou <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 2.1.0 |
| Built: | 2026-10-08 02:12:35 UTC |
| Source: | https://github.com/jiezhou-2/lglasso |
lglasso
The function computes the cross validation errors in lglasso.
CVlglasso( data, K, group = NULL, random = FALSE, lambda = NULL, nlam = 10, lam.min.ratio = 0.01, expFix = 1, trace = FALSE )CVlglasso( data, K, group = NULL, random = FALSE, lambda = NULL, nlam = 10, lam.min.ratio = 0.01, expFix = 1, trace = FALSE )
data |
same as in |
K |
fold number for the cross validation |
group |
same as in |
random |
same as in |
lambda |
tuning parameter. For one-stage model, lambda is a vector. For two-stage model, lambda is a 2-column matrix. The first column is tuning parameter controlling the sparsity, the second column is tuning parameter controlling the similarity of two networks. |
nlam |
If |
lam.min.ratio |
ratio of largest lambda vs smallest lambda |
expFix |
same as in |
trace |
logical variable. Whether show the computation process |
list of length 2. The first component is the cross validation errors, the second component is the corresponding tuning parameters
This function estimates precision matrices(networks) and random effects from longitudinal high-dimensional data under normality assumption.
lglasso( data, lambda, group = NULL, random = FALSE, expFix = 1, N = 100, maxit = 50, tol = 10^(-2), lower = c(0.01, 0.01), upper = c(10, 10), w.init = NULL, wi.init = NULL, trace = FALSE, ... )lglasso( data, lambda, group = NULL, random = FALSE, expFix = 1, N = 100, maxit = 50, tol = 10^(-2), lower = c(0.01, 0.01), upper = c(10, 10), w.init = NULL, wi.init = NULL, trace = FALSE, ... )
data |
|
lambda |
numerical vector of tuning parameters. For one-stage model, |
group |
factor of length |
random |
a logical variable. If TRUE, then a heterogeneous model is fitted. Otherwise, a homogeneous model is fitted. |
expFix |
numerical number specifying the exponent in the covariance function of the longitudinal data. Default is 1. |
N |
a integer specifying the number of sampling for heterogeneous model |
maxit |
integer specifying the maximum iterations for the algorithms. |
tol |
a small number determining whether the algorithms converged and should stop. |
lower |
vector of length 1 or 2 which specifies the lower bounds for temporal correlation |
upper |
vector of length 1 or 2 which specifies the upper bounds for temporal correlation |
w.init |
initial value for covariance matrix. Default is identity matrix. |
wi.init |
initial value for precision matrix. Default is identity matrix. |
trace |
whether or not show the progress of the computation |
... |
other inputs |
lglasso is developed to estimate precision matrices, or networks, and random effects
from high-dimensional longitudinal data.
The one-stage model in lglasso is proposed in Zhou et al (2024).
Currently, it contains two network identification models,
i.e., one-stage and two-stage model.
One-stage model assume a common network underlying
the longitudinal data for all the subjects. Consequently,
the function outputs a single network as the estimate in this case.
In two-stage models, a treatment is applied at time during the time interval
for subject .
Therefore, there are two networks, i.e., pre- and post-treatment networks, that need to be estimated simultaneously.
For details, please check the reference paper
and the online resources.
A list which includes:
w: the list of the estimates for covariance matrices
wi: the list of the estimates for precision matrices
tau: the estimate of dampening rate tau. For heterogeneous models, the
output is a vector called random effects. For homogeneous model, the output is a scalar.
alpha: a scalar representing the estimate of the parameter in exponential distribution of tau for heterogeneous models.
The output is NULL for homogeneous model
ll: the likelihood. ll is used to compute extended QIC for tuning parameter selection
## Not run: library(lglasso) # number of nodes p=15 # number of edge in general network m1=20 # the difference between the number of edges in individual networks and general network m2=5 # number of subjects n=30 set.seed(1) ## One-stage model ### Estimate the network based on homogeneous one-stage model ####simulate data dd=Simulate(type="homo",n=n,p=p,m1=m1,m2=m2,tau=2,tt=10) ddata=dd$data dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = 0.01,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated network estimates #### true network dd$network #### correlation parameter aa$tau #### likelihood aa$ll ### Estimate the network based on heterogeneous one-stage model ####simulate data dd=Simulate(type="heter",n=n,p=p,m1=m1,m2=m2,tt=10,alpha=5,group = 1) ddata=dd$data$pre dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = 0.01,random=TRUE,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated network estimates #### true network dd$network #### likelihood aa$ll ## Two-stage model ### Estimate the networks based on homogeneous two-stage model ####simulate data dd=Simulate(type="homo",n=n,p=p,m1=m1,m2=m2,tau=c(2,1),tt=10) ddata=do.call(rbind,dd$data) group=c(rep(0,nrow(ddata)/2),rep(1,nrow(ddata)/2)) dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = c(0.01,0.01),group = group,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated pre-treatment network estimates[[1]] #### true pre-treatment network dd$network$pre #### estimated post-treatment network estimates[[2]] #### true post-treatment network dd$network$post #### correlation parameters aa$tau #### likelihood aa$ll ### Estimate the networks based on heterogeneous two-stage model ####simulate data dd=Simulate(type="heter",n=n,p=p,m1=m1,m2=m2,tt=10,alpha=0.5,group=2) ddata=do.call(rbind,dd$data) group=c(rep(0,nrow(ddata)/2),rep(1,nrow(ddata)/2)) dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = c(0.01,0.01),random=TRUE,group = group,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated pre-treatment network estimates[[1]] #### true pre-treatment network dd$network$pre #### estimated post-treatment network estimates[[2]] #### true post-treatment network dd$network$post #### likelihood aa$ll ## End(Not run)## Not run: library(lglasso) # number of nodes p=15 # number of edge in general network m1=20 # the difference between the number of edges in individual networks and general network m2=5 # number of subjects n=30 set.seed(1) ## One-stage model ### Estimate the network based on homogeneous one-stage model ####simulate data dd=Simulate(type="homo",n=n,p=p,m1=m1,m2=m2,tau=2,tt=10) ddata=dd$data dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = 0.01,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated network estimates #### true network dd$network #### correlation parameter aa$tau #### likelihood aa$ll ### Estimate the network based on heterogeneous one-stage model ####simulate data dd=Simulate(type="heter",n=n,p=p,m1=m1,m2=m2,tt=10,alpha=5,group = 1) ddata=dd$data$pre dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = 0.01,random=TRUE,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated network estimates #### true network dd$network #### likelihood aa$ll ## Two-stage model ### Estimate the networks based on homogeneous two-stage model ####simulate data dd=Simulate(type="homo",n=n,p=p,m1=m1,m2=m2,tau=c(2,1),tt=10) ddata=do.call(rbind,dd$data) group=c(rep(0,nrow(ddata)/2),rep(1,nrow(ddata)/2)) dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = c(0.01,0.01),group = group,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated pre-treatment network estimates[[1]] #### true pre-treatment network dd$network$pre #### estimated post-treatment network estimates[[2]] #### true post-treatment network dd$network$post #### correlation parameters aa$tau #### likelihood aa$ll ### Estimate the networks based on heterogeneous two-stage model ####simulate data dd=Simulate(type="heter",n=n,p=p,m1=m1,m2=m2,tt=10,alpha=0.5,group=2) ddata=do.call(rbind,dd$data) group=c(rep(0,nrow(ddata)/2),rep(1,nrow(ddata)/2)) dim(ddata) ddata[1:2,1:5] #### Estimation aa=lglasso(data=ddata,lambda = c(0.01,0.01),random=TRUE,group = group,trace=TRUE) estimates=lapply(aa$wi,function(ll){ifelse(abs(ll)>10^(-5),1,0)}) #### estimated pre-treatment network estimates[[1]] #### true pre-treatment network dd$network$pre #### estimated post-treatment network estimates[[2]] #### true post-treatment network dd$network$post #### likelihood aa$ll ## End(Not run)
This function randomly generates precision matrices (networks) and then simulates normal data that follows these network structures.
Simulate( type = c("homo", "heter"), n, p, m1, m2, tt, tau, alpha = 1, group = 1 )Simulate( type = c("homo", "heter"), n, p, m1, m2, tt, tau, alpha = 1, group = 1 )
type |
which type of data you are generating. There are two options. One is |
n |
the number of subjects in the data set |
p |
the dimension of the normal distribution |
m1 |
the number of edges in true networks |
m2 |
the edge difference between two networks |
tt |
the average time points for each subject |
tau |
the true dampening rate in homogeneous models |
alpha |
the true parameter in exponential distribution of tau when |
group |
a scalar of 1 or 2, indicating one-stage or two-stage model. |
a data list. It includes the data generated, true networks underlying the data,true tau.
If type is heter, then true parameter alpha is included as well.