knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  cache=TRUE
)
library(ggplot2)
library(dplyr)
library(tidyr)
library(magrittr)
library(EMtree)

Partial correlations simulation

set.seed(1)
p=300
n=400
simulation<-data_from_scratch(type="erdos",p=p,n=n,signed=TRUE, dens=3/p)
G=1*(simulation$omega!=0) ; diag(G) = 0
draw_network(G, remove_isolated = TRUE, pal_edges = "gray70",pal_nodes = "steelblue",btw_rank = 1)$G

simulated partial correlation matrix :

ParCor <- - cov2cor(simulation$omega)
ParCor %>% ToVec() %>% as_tibble() %>% filter(value!=0) %>% 
  ggplot(aes(value))+geom_histogram(alpha=0.8)+
  theme_light()+labs(title="Repartition of non-nul partial correlations",
                     x="Partial correlation values")

Inference

EMtreefit<-ResampleEMtree(simulation$data,S = 30,cores = 3)
stab_selection=StATS(EMtreefit$Pmat, nlambda=50, stab.thresh=0.8,plot=TRUE)
net90=ToSym(1*(stab_selection$freqs_opt>0.95))
table(net90, G)
library(PRROC)
pr<-pr.curve(scores.class0 = stab_selection$freqs_opt,
             scores.class1 = ToVec(G))
pr


Rmomal/EMtree documentation built on Dec. 14, 2024, 8:16 a.m.