This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(haven)
Warning: package ‘haven’ was built under R version 4.2.2
library(tidyverse)
Warning: package ‘tidyverse’ was built under R version 4.2.2Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
── Attaching packages ────────────────────────────────────────────────── tidyverse 1.3.2 ──✔ ggplot2 3.4.0 ✔ purrr 1.0.1
✔ tibble 3.1.8 ✔ dplyr 1.0.10
✔ tidyr 1.2.1 ✔ stringr 1.5.0
✔ readr 2.1.3 ✔ forcats 0.5.2 Warning: package ‘ggplot2’ was built under R version 4.2.2Warning: package ‘tibble’ was built under R version 4.2.2Warning: package ‘tidyr’ was built under R version 4.2.2Warning: package ‘readr’ was built under R version 4.2.2Warning: package ‘purrr’ was built under R version 4.2.2Warning: package ‘dplyr’ was built under R version 4.2.2Warning: package ‘stringr’ was built under R version 4.2.2Warning: package ‘forcats’ was built under R version 4.2.2── Conflicts ───────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
library(EGAnet)
Warning: package ‘EGAnet’ was built under R version 4.2.2
EGAnet (version 1.2.3)
For help getting started, type browseVignettes("EGAnet")
For bugs and errors, submit an issue to <https://github.com/hfgolino/EGAnet/issues>
library(lavaan)
Warning: package ‘lavaan’ was built under R version 4.2.2This is lavaan 0.6-13
lavaan is FREE software! Please report any bugs.
library(bootnet)
Warning: package ‘bootnet’ was built under R version 4.2.2Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 method overwritten by 'mgm':
method from
print.resample modelr
This is bootnet 1.5
For questions and issues, please see github.com/SachaEpskamp/bootnet.
acute.clean <- Acute_Care_Years %>%
select(.,
DXMOOD,
DXANXIETY,
DXBEHAVIOR,
DXPSYCHOTIC,
DXMIOTHER,
SELFINJ,
DISBEH,
UNCPBEH,
HCCARVAS,
HCDIAB,
HCHIBP,
HCHICHL,
HCDYSPH,
HCPRESULC,
HCALZHEIM,
HCORALDENTAL,
HCSLEEPAPNEA,
HEALTH,
PRIMARY_VISIT_Total,
OUTPATIENT_COUNSELING_TOTAL,
INPATIENT_MH_TOTAL,
ER_Total,
scr_1A_raw_total,
scr_1B_raw_total)%>%
na_if(., -9) %>%
na_if(., -99) %>%
na_if(., -999) %>%
na_if(., 98) %>%
na_if(., 99)%>%
na.omit
model.health <- acute.clean %>%
select(.,
DXMOOD,
DXANXIETY,
DXBEHAVIOR,
DXPSYCHOTIC,
DXMIOTHER,
SELFINJ,
DISBEH,
UNCPBEH,
HCCARVAS,
HCDIAB,
HCHIBP,
HCHICHL,
HCDYSPH,
HCPRESULC,
HCALZHEIM,
HCORALDENTAL,
HCSLEEPAPNEA)
ega.health <- EGA(data = model.health, model = "glasso")
summary(ega.health)
Number of communities: 4
DXMOOD DXANXIETY DXBEHAVIOR DXPSYCHOTIC DXMIOTHER SELFINJ
2 2 4 2 2 4
DISBEH UNCPBEH HCCARVAS HCDIAB HCHIBP HCHICHL
4 4 1 1 1 1
HCDYSPH HCPRESULC HCALZHEIM HCORALDENTAL HCSLEEPAPNEA
3 3 3 3 1
Methods:
Correlations = auto (from qgraph)
Model = glasso
Algorithm = walktrap
Unidimensional Method = louvain with consensus clustering
centab <- centralityTable(health=ega.health$network, standardized = TRUE, relative = FALSE, weighted = TRUE, signed = TRUE)
centab
EI.health <- filter(centab, measure == "ExpectedInfluence")
EI.health
EI.health.order <- EI.health[order(EI.health$value),]
EI.health.order
EI_plot <- ggplot(EI.health.order, aes (x=value, y = node))+ geom_point()
print(EI_plot)