#Title”Readiness responding with covid-19” #Author” le dinh duong” #Date”12/2/2022”

library(readxl) data <- read_excel(“C:/Users/Admin/OneDrive - huemed-univ.edu.vn/PUBLIC/2021 Elearning _Minhtu/data.xlsx”) View(data)

Network analysis

##Required libraries library(“readxl”) library(qgraph) library(ggplot2) library(JGR) library(rJava) library(huge) library(“psychTools”) library(reshape2) library(NetworkComparisonTest) library(data.table) library(“Deducer”)

Set the random seed:

set.seed(123) #data male<-subset(data, sex==“1”) female<-subset(data, sex==“2”)

#setnames

#Reset names setnames (male, old = c(“computerskill”, “internet”, “communication”, “motivation”,“selfcontrol”, “selflearning”), new = c(“CS”,“IA”,“OC”,“M”, “SC”,“SL”)) setnames (female, old = c(“computerskill”, “internet”, “communication”, “motivation”,“selfcontrol”, “selflearning”), new = c(“CS”,“IA”,“OC”,“M”, “SC”,“SL”)) setnames (data, old = c(“computerskill”, “internet”, “communication”, “motivation”,“selfcontrol”, “selflearning”), new = c(“CS”,“IA”,“OC”,“M”, “SC”,“SL”)) #define catogorical variable.names data\(sex=as.factor(data\)sex) data\(year=as.factor(data\)year) data\(major=as.factor(data\)major) data\(resident=as.factor(data\)resident) data\(livingcost=as.factor(data\)livingcost)

#install.packages(table1) #install.packages(compareGroups) library(table1) library(compareGroups)

#tabel 1. General characteristics; wellbeing and readiness score table1(sex~sex+age+year+major+resident+livingcost+wellbeing+CS+IA+OC+M+SC+SL+total, data=data) t1=compareGroups(sex~sex+age+year+major+resident+livingcost+wellbeing+CS+IA+OC+M+SC+SL+total, data=data) t1 createTable(t1) names(data)

shapiro.test(data$IA) who5 <- wilcox.test(wellbeing~sex,data=data) who5 CS<-wilcox.test(CS~sex,data=data) CS IA<-wilcox.test(IA~sex,data=data) IA OC<-wilcox.test(OC~sex,data=data) OC M<-wilcox.test(M~sex,data=data) M SC<-wilcox.test(SC~sex,data=data) SC SL<-wilcox.test(SL~sex,data=data) SL total<-wilcox.test(total~sex,data=data) total

#Network structure correlation #create data data1 <- data[, c(‘CS’,‘IA’, ‘OC’, ‘M’, ‘SC’, ‘SL’ )] male1<-male[,c(‘CS’,‘IA’, ‘OC’, ‘M’, ‘SC’, ‘SL’ )] female1<-female[,c(‘CS’,‘IA’, ‘OC’, ‘M’, ‘SC’, ‘SL’ )] #transforme data tdata1<-huge.npn(data1) tmale1 <- huge.npn(male1) tfemale1 <- huge.npn(female1)

#correlation library(Hmisc) cortdata1<-cor_auto(tdata1) cortmale1<-cor_auto(tmale1) cortfemale1<-cor_auto(tfemale1)

#graph

graph <- qgraph(EBICglasso(cortdata1, nrow(tdata1), lambda.min.ratio=0.01, gamma=0.5, threshold = TRUE), labels=c(‘Computer skill’,‘Internet ability’,‘Online communicationi’,‘Motivation’,‘Self control’,‘Self learning’), color=‘#FFCC66’, label.scale=FALSE,edge.labels=TRUE, edge.color=‘#993300’)

graph <- qgraph(EBICglasso(cortmale1, nrow(tmale1), lambda.min.ratio=0.01, gamma=0.5, threshold = TRUE), labels=c(‘Computer skill’,‘Internet ability’,‘Online communicationi’,‘Motivation’,‘Self control’,‘Self learning’), color=‘#FFCC66’, label.scale=FALSE,edge.labels=TRUE, edge.color=‘#993300’)

graph <- qgraph(EBICglasso(cortfemale1, nrow(tfemale1), lambda.min.ratio=0.01, gamma=0.5, threshold = TRUE), color=‘#FFCC66’, label.scale=FALSE,edge.labels=TRUE, edge.color=‘#993300’)

#estimate network library(‘bootnet’) net1 <- estimateNetwork(tdata1,default = “EBICglasso”,corMethod = “cor_auto”,tuning = 0.5) net2 <- estimateNetwork(tmale1,default = “EBICglasso”,corMethod = “cor_auto”,tuning = 0.5) net3 <- estimateNetwork(tfemale1,default = “EBICglasso”,corMethod = “cor_auto”,tuning = 0.5)

#get matrix

#get matrices net1\(graph net2\)graph net3$graph plot #Plot

L <- averageLayout(net1, net2, net3) n1=plot(net1, title=“a)”, cut = 0.03,negDashed=TRUE,layout = L) n2=plot(net2, title=“b)”, cut = 0.03,negDashed=TRUE,layout = L) n3=plot(net3, title=“c)”, cut = 0.03,negDashed=TRUE,layout = L)

#centrality

Cent1 <- centralityTable(tdata1, standardized = TRUE) cent1 Cent2 <- centralityTable(m2, standardized = TRUE) Cent2 Cent3 <- centralityTable(m3, standardized = TRUE)

centralityPlot(Centrality = list(“total” = net1,“male” = net2, “female”=net3), include=c(“Strength”,“Closeness”, “Betweenness”), labels = names(student),decreasing=T)+ theme(legend.title = element_blank())

#Stability

b1 <- bootnet(net1, nCores = 8,nBoots = 1000, type = ‘nonparametric’) b2 <- bootnet(net1, nCores = 8,nBoots = 1000, type = ‘case’, statistics=c(‘strength’,‘closeness’,‘betweenness’)) b3 <- bootnet(net2, nCores = 8,nBoots = 1000, type = ‘nonparametric’) b4 <- bootnet(net2, nCores = 8,nBoots = 1000, type = ‘case’, statistics=c(‘strength’,‘closeness’,‘betweenness’)) b5 <- bootnet(net3, nCores = 8,nBoots = 1000, type = ‘nonparametric’) b6 <- bootnet(net3, nCores = 8,nBoots = 1000, type = ‘case’, statistics=c(‘strength’,‘closeness’,‘betweenness’)) b1 #total plot(b1, order=“sample”, plot=“area”, prop0=F)# confidence intervals plot(b1, “edge”, plot = “difference”, onlyNonZero = TRUE, order = “sample”) # difference of edges plot(b1, “strength”, plot = “difference”) # node strength #male plot(b3, order=“sample”, plot=“area”, prop0=F)# confidence intervals plot(b3, “edge”, plot = “difference”, onlyNonZero = TRUE, order = “sample”) # difference of edges plot(b3, “strength”, plot = “difference”) # node strength plot(b4 ,statistics=c(‘strength’,‘closeness’,‘betweenness’))+ theme(legend.title = element_blank()) #female plot(b5, order=“sample”, plot=“area”, prop0=F)# confidence intervals plot(b5, “edge”, plot = “difference”, onlyNonZero = TRUE, order = “sample”) # difference of edges plot(b5, “strength”, plot = “difference”) # node strength plot(b6 ,statistics=c(‘strength’,‘closeness’,‘betweenness’))+ theme(legend.title = element_blank())

corStability(b2 ) corStability(b4 ) corStability(b6 )

##Network comparsion test

nct1<- NCT(net1, net2, it=1000,paired = FALSE,test.edges = TRUE,edges=“all”, test.centrality=TRUE,centrality=c(“strength”,“closeness”,“betweenness”)) nct2<- NCT(net1, net3, it=1000,paired = FALSE,test.edges = TRUE,edges=“all”, test.centrality=TRUE,centrality=c(“strength”,“closeness”,“betweenness”)) nct3<- NCT(net2, net3, it=1000,paired = TRUE,test.edges = TRUE,edges=“all”, test.centrality=TRUE,centrality=c(“strength”,“closeness”,“betweenness”))

nct1 nct2 nct3

Perform permutation test

library(“NetworkToolbox”) perm.str <- network.permutation(net2, net3, iter = 1000, network = “glasso”, measure = “strength”, alternative = “two.tailed”, ncores = 4)

#Average shortest path length perm.aspl <- network.permutation(prev.perm = perm.str, measure = “ASPL”, ncores = 4)

#Average clustering coefficient perm.aspl <- network.permutation(prev.perm = perm.str, measure = “CC”, ncores = 4) # Modularity quality index perm.aspl <- network.permutation(prev.perm = perm.str, measure = “Q”, ncores = 4) #smallworldness perm.aspl <- network.permutation(prev.perm = perm.str, measure = “S”, ncores = 4) # Check results perm.aspl$result #density install.packages(“quanteda.textplots”) library(igraph) g=as.igraph(n2, attributes=TRUE) plot(n2) a<-(degree(g))/(vcount(g)-1) g <- as.igraph(n3, attributes=TRUE) b<-(degree(g))/(vcount(g)-1) t.test(a,b,statistic=c(“t”,“mean”),alternative=c(“two.sided”), midp=TRUE, B=1000)

##Represent Node sizes represent the difference of centrality #strength Cent2 <- centralityTable(net2, standardized = TRUE) Cent3 <- centralityTable(net3, standardized = TRUE) table.data1 <- data.frame(“Item” = Cent2[Cent2$measure == “Strength”,3], “Strength” = Cent2[Cent2$measure == “Strength”,5]) table.data2 <- data.frame(“Item” = Cent3[Cent3$measure == “Strength”,3], “Strength” = Cent3[Cent3$measure == “Strength”,5]) data3 <- table.data1[,2] data4 <- table.data2[,2] data5=data4-data3 plot(net1, title=“a)”, cut = 0.03,negDashed=TRUE,layout = L,vsize =data310,esize=14) plot(net2, title=“b)”, cut = 0.03,negDashed=TRUE,layout = L,vsize =data410,esize=14) plot(net3, title=“c)”, cut = 0.03,negDashed=TRUE,layout = L,vsize =data5*10,esize=14) data3 date4 data5