title: “Social network analysis” author: “THONG NGUYEN” date: “1/2/2020” output: html_document html_document: code_download: true code_folding: hide number_sections: yes theme: “default” toc: TRUE toc_float: TRUE dev: ‘svg’
library("readxl")
library(huge)
library(qgraph)
## Registered S3 methods overwritten by 'BDgraph':
## method from
## plot.sim huge
## print.sim huge
#Raw data
BS <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "BS")
## New names:
## * PANSS.P.TO...16 -> PANSS.P.TO
## * PANSS.N.TO...24 -> PANSS.N.TO
## * PANSS.G.TO...41 -> PANSS.G.TO
## * BCSS.NS...111 -> BCSS.NS
## * BCSS.PS...112 -> BCSS.PS
## * ... and 4 more problems
TM <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "TM")
## New names:
## * PANSS.P.TO...171 -> PANSS.P.TO
## * PANSS.N.TO...179 -> PANSS.N.TO
## * PANSS.G.TO...196 -> PANSS.G.TO
## * BCSS.NS...234 -> BCSS.NS
## * BCSS.PS...235 -> BCSS.PS
## * ... and 4 more problems
BHR <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "BHR")
## New names:
## * PANSS.P.TO...16 -> PANSS.P.TO
## * PANSS.N.TO...24 -> PANSS.N.TO
## * PANSS.G.TO...41 -> PANSS.G.TO
## * BCSS.NS...111 -> BCSS.NS
## * BCSS.PS...112 -> BCSS.PS
## * ... and 4 more problems
THR <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "THR")
## New names:
## * PANSS.P.TO...171 -> PANSS.P.TO
## * PANSS.N.TO...179 -> PANSS.N.TO
## * PANSS.G.TO...196 -> PANSS.G.TO
## * BCSS.NS...234 -> BCSS.NS
## * BCSS.PS...235 -> BCSS.PS
## * ... and 4 more problems
BLR <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "BLR")
## New names:
## * PANSS.P.TO...16 -> PANSS.P.TO
## * PANSS.N.TO...24 -> PANSS.N.TO
## * PANSS.G.TO...41 -> PANSS.G.TO
## * BCSS.NS...111 -> BCSS.NS
## * BCSS.PS...112 -> BCSS.PS
## * ... and 4 more problems
TLR <- read_excel("D:/Research/REFERENCES/Statistic/Network analysis/PROJECT/Data/Raw data.xlsx",sheet = "TLR")
## New names:
## * PANSS.P.TO...171 -> PANSS.P.TO
## * PANSS.N.TO...179 -> PANSS.N.TO
## * PANSS.G.TO...196 -> PANSS.G.TO
## * BCSS.NS...234 -> BCSS.NS
## * BCSS.PS...235 -> BCSS.PS
## * ... and 4 more problems
BS=sapply(BS,as.numeric)
TM=sapply(TM,as.numeric)
BLR=sapply(BLR,as.numeric)
BHR=sapply(BHR,as.numeric)
THR=sapply(THR,as.numeric)
TLR=sapply(TLR,as.numeric)
#Delete MV
BS <- na.omit(BS)
TM <- na.omit(TM)
BHR <- na.omit(BHR)
BLR <- na.omit(BLR)
THR <- na.omit(THR)
TLR <- na.omit(TLR)
#Transformation
BS1 <- huge.npn(BS )
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
TM1<- huge.npn(TM)
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
BLR1 <- huge.npn(BLR )
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
BHR1<- huge.npn(BHR)
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
THR1 <- huge.npn(THR )
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
TLR1<- huge.npn(TLR)
## Conducting the nonparanormal (npn) transformation via shrunkun ECDF....done.
# Compute correlations:
BS2 <- cor_auto(BS1)
TM2 <- cor_auto(TM1)
BLR2 <- cor_auto(BLR1)
BHR2 <- cor_auto(BHR1)
TLR2 <- cor_auto(TLR1)
THR2 <- cor_auto(THR1)
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.