46 lines
1.1 KiB
R
46 lines
1.1 KiB
R
library(colSBM)
|
|
library(here)
|
|
library(tidyverse)
|
|
library(future.apply)
|
|
|
|
read.csv(here("data", "projects_supinfo.csv.gz")) -> projects_supinfo
|
|
|
|
projects_supinfo %>%
|
|
group_by(country, project) %>%
|
|
distinct() %>%
|
|
count()
|
|
|
|
|
|
list_matrices <- readRDS(here("data", "list_matrices.rds"))
|
|
|
|
names(list_matrices)
|
|
|
|
portuguese_projects <- projects_supinfo %>%
|
|
filter(country == "Portugal") %>%
|
|
select(project) %>%
|
|
distinct() %>%
|
|
pull() %>%
|
|
as.vector()
|
|
|
|
portuguese_matrices <- list_matrices[portuguese_projects]
|
|
|
|
rm(list_matrices)
|
|
|
|
binary_portuguese_matrices <- lapply(portuguese_matrices, function(x) {
|
|
x[x > 0] <- 1
|
|
x
|
|
})
|
|
options(future.globals.maxSize = Inf)
|
|
plan(multisession, workers = 3L)
|
|
set.seed(123)
|
|
fit_portuguese <- estimate_colBiSBM(
|
|
netlist = binary_portuguese_matrices,
|
|
colsbm_model = "iid",
|
|
net_id = names(binary_portuguese_matrices),
|
|
global_opts = list(backend = "no_mc")
|
|
)
|
|
save_path <- here("results", "colSBM")
|
|
if (!dir.exists(save_path)) {
|
|
dir.create(save_path, recursive = TRUE)
|
|
}
|
|
saveRDS(fit_portuguese, file = here(save_path, "colSBM_portuguese.rds"))
|