Identify networks from longitudinal data (2)

# number of nodes
p=20
# number of edge in general network
m1=50
# the difference between the number of edges in individual networks and general network
m2=10
# number of subjects
n=50
## number of time points
tt=10

Model 1: homogeneous individuals

dd=Simulate(type="homo",n=n,p=p,m1=m1,m2=m2,tt=10,tau=c(2,1))
data1=cbind(1,dd$data$pre)
colnames(data1)[1]="group"
data2=cbind(2,dd$data$post)
colnames(data2)[1]="group"
ddata=rbind(data1,data2)
lambda1=exp(seq(-5,-1,length=5))
lambda2=lambda1[1:2]
lambda=expand.grid(lambda1,lambda2)

dim(ddata)
#> [1] 548  23
ddata[1:5,1:5]
#>   group  subject     time         V1         V2
#> 1     1 subject1 1.181643 -0.1393319  0.1637008
#> 2     1 subject1 1.327350 -0.6731418 -0.5557598
#> 3     1 subject1 1.467145  0.2287267 -0.3197708
#> 4     1 subject1 1.903213  0.1032342  0.6995483
#> 5     1 subject1 4.798182 -0.3205186  0.7497682

one-stage model

 bb=CVlglasso(data=data1[,-1],nlam =  100,K=10)
#> 
#> Number of cores used = 14
plot(bb)

two-stage model

table(ddata[,1])
#> 
#>   1   2 
#> 274 274
bb=CVlglasso(data=ddata[,-1],nlam = 10,group=ddata[,1],K=10)
#> 
#> Number of cores used = 14
plot(bb)

Model 2: heterogeneous individuals

dd=Simulate(type="heter",n=n,p=p,m1=m1,m2=m2,tt=tt,alpha=2,group=2)
data1=cbind(1,dd$data$pre)
colnames(data1)[1]="group"
data2=cbind(2,dd$data$post)
colnames(data2)[1]="group"
ddata=rbind(data1,data2)

lambda1=exp(seq(-5,0,length=5))
lambda2=exp(seq(-5,-0,length=2))
lambda=expand.grid(lambda1,lambda2)
dim(ddata)
#> [1] 514  23
ddata[1:5,1:5]
#>   group  subject      time          V1         V2
#> 1     1 subject1 0.6968137 -0.15873792 -0.8547846
#> 2     1 subject1 1.5863664 -0.05490448 -0.8663066
#> 3     1 subject1 3.0773906 -0.18820877 -0.7081670
#> 4     1 subject1 5.9196679 -0.22311076 -0.7828992
#> 5     1 subject1 6.2327715 -0.20642160 -0.7833975

one-stage model


bb=CVlglasso(data=data1[,-1],nlam = 100,K=10,random=TRUE)
#> 
#> Number of cores used = 14
plot(bb)

two-stage model

table(ddata[,1])
#> 
#>   1   2 
#> 257 257
bb=CVlglasso(data=ddata[,-1],group=ddata[,1],nlam = 10,K=10,random = TRUE)
#> 
#> Number of cores used = 14
plot(bb)