From 56a598d6fbc110208cc3691d401bf69c936e0015 Mon Sep 17 00:00:00 2001 From: JHart96 Date: Tue, 18 Jun 2024 16:37:04 +0100 Subject: [PATCH] plot_network edgelist fix --- .Rhistory | 562 ++++++++++++++++++++++++------------------------ R/bison_model.R | 4 +- 2 files changed, 283 insertions(+), 283 deletions(-) diff --git a/.Rhistory b/.Rhistory index a8e73a6..d7db55c 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,284 +1,3 @@ -priors <- expect_warning(bison_brm_get_prior( -age_diff ~ bison(edge_weight(node_1_id, node_2_id)), -list(fit_edge, fit_edge), -list(df_sim, df_sim) -), -regexp=NA -) -fit_edge -bison_brm_get_prior( -age_diff ~ bison(edge_weight(node_1_id, node_2_id)), -list(fit_edge, fit_edge), -list(df_sim, df_sim) -) -devtools::load_all(".") -priors <- expect_warning(bison_brm_get_prior( -age_diff ~ bison(edge_weight(node_1_id, node_2_id)), -list(fit_edge, fit_edge), -list(df_sim, df_sim) -), -regexp=NA -) -priors -devtools::document() -devtools::load_all(".") -devtools::load_all(".") -sim_data <- simulate_bison_model("binary", aggregated = TRUE) -df <- sim_data$df_sim -df$node_1_id -"A":"F" -f$node_1_id -node_names <- c("A", "B", "C", "D", "E", "F", "G", "H") -df$node_1_id -node_names[df$node_1_id] -node_names <- sample(c("A", "B", "C", "D", "E", "F", "G", "H")) -node_names -node_names <- c("G", "B", "A", "D", "C", "H", "F", "E") -node_names[df$node_1_id] -df$node_1_id -node_names <- c("G", "B", "A", "D", "J", "C", "H", "F", "E", "K") -node_names[df$node_1_id] -sim_data <- simulate_bison_model("binary", aggregated = TRUE) -df <- sim_data$df_sim -node_names <- c("G", "B", "A", "D", "J", "C", "H", "F", "E", "K") -df$node_1_name <- node_names[df$node_1_id] -df$node_2_name <- node_names[df$node_2_id] -df -fit_edge <- bison_model( -(event | duration) ~ dyad(node_1_id, node_2_id), -data=df, -model_type="binary_conjugate", -priors=get_default_priors("binary_conjugate") -) -x <- expect_warning( -extract_metric(fit_edge, "edge_weight", num_draws=10), -regexp=NA -) -expect_equal(dim(x)[1], 10) -x -draw_edgelist_samples(obj, num_draws) -draw_edgelist_samples(fit_edge, 2) -devtools::load_all(".") -extract_metric(fit_edge, "edge_weight", num_draws=10) -extract_metric(fit_edge, "node_strength", num_draws=50) -fit_edge$node_to_idx -df$node_1_name <- node_names[df$node_1_id] -df$node_2_name <- node_names[df$node_2_id] -fit_edge <- bison_model( -(event | duration) ~ dyad(node_1_name, node_2_name), -data=df, -model_type="binary_conjugate", -priors=get_default_priors("binary_conjugate") -) -draw_edgelist_samples(fit_edge, 2) -extract_metric(fit_edge, "edge_weight", num_draws=10) -extract_metric(fit_edge, "node_strength", num_draws=50) -devtools::load_all(".") -extract_metric(fit_edge, "node_strength", num_draws=50) -sim_data <- simulate_bison_model("binary", aggregated = TRUE) -df <- sim_data$df_sim -node_names <- c("G", "B", "A", "D", "J", "C", "H", "F", "E", "K") -df$node_1_name <- node_names[df$node_1_id] -df$node_2_name <- node_names[df$node_2_id] -fit_edge <- bison_model( -(event | duration) ~ dyad(node_1_name, node_2_name), -data=df, -model_type="binary_conjugate", -priors=get_default_priors("binary_conjugate") -) -draw_edgelist_samples(fit_edge, 2) -extract_metric(fit_edge, "edge_weight", num_draws=10) -extract_metric(fit_edge, "node_strength", num_draws=50) -sim_data$df_sim -df -df_2 <- df[,c("node_1_name", "node_2_name")] -df$weight <- df$event/df$duration -df_2 <- df[,c("node_1_name", "node_2_name")] -df_2$weight <- df$event/df$duration -df_2$weight -df_2$weight -?igraph::from_edgelist -net <- igraph::from_edgelist(df[, c("node_1_name", "node_2_name")]) -net <- igraph::from_edgelist(df[, c("node_1_name", "node_2_name")]) -E(net)$weight <- df$event/df$duration -E(net) -net <- igraph::from_edgelist(df[, c("node_1_name", "node_2_name")]) -net -E(net) -net -df[, c("node_1_name", "node_2_name")] -igraph::from_edgelist(df[, c("node_1_name", "node_2_name")]) -net <- from_edgelist(df[, c("node_1_name", "node_2_name")]) -net -net <- graph_from_edgelist(df[, c("node_1_name", "node_2_name")]) -df[, c("node_1_name", "node_2_name")] -raph_from_edgelist(matrix(df[, c("node_1_name", "node_2_name")])) -graph_from_edgelist(matrix(df[, c("node_1_name", "node_2_name")])) -matrix(df[, c("node_1_name", "node_2_name")]) -df -df[, c("node_1_name", "node_2_name")] -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")])) -net -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net) <- df$event/df$duration -E(net) -df$event/df$duration -E(net)$weight <- df$event/df$duration -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -strength(net) -x -net -strength(net) -x[1, ] -cor(strength(net), x[1, ]) -strength(net) -x[1, ] -cor(strength(net), x[, 1]) -V(net) -colnames(x) -x -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -x[, 1] -x[1, ] -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -x <- expect_warning( -extract_metric(fit_edge, "node_strength", num_draws=50), -regexp=NA -) -net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=FALSE) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) -net <- graph_from_edgelist(as.matrix(df[, c("node_1_name", "node_2_name")]), directed=T) -E(net)$weight <- df$event/df$duration -cor(strength(net), x[1, ]) net <- graph_from_edgelist(as.matrix(df[, c("node_2_name", "node_1_name")]), directed=T) E(net)$weight <- df$event/df$duration cor(strength(net), x[1, ]) @@ -510,3 +229,284 @@ devtools::document() devtools::install() devtools::load_all(".") devtools::test_active_file() +devtools::test_active_file() +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +tidy.opts=list(width.cutoff=80), +tidy=TRUE +) +library(bisonR) +library(dplyr) +sim_data <- simulate_bison_model("binary", aggregated = FALSE) +df <- sim_data$df_sim +head(df) +priors <- get_default_priors("binary") +priors +prior_check(priors, "binary") +priors$edge <- "normal(-1, 2.5)" +prior_check(priors, "binary") +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary", +priors=priors +) +plot_trace(fit_edge, par_ids=2) +plot_predictions(fit_edge, num_draws=20, type="density") +plot_predictions(fit_edge, num_draws=20, type="point") +summary(fit_edge) +plot_network(fit_edge, lwd=5) +fit_null <- bison_model( +(event | duration) ~ 1, +data=df, +model_type="binary", +priors=priors +) +model_comparison(list(non_random_model=fit_edge, random_model=fit_null)) +df_dyadic <- df %>% +distinct(node_1_id, node_2_id, age_diff) +df_dyadic +fit_dyadic <- bison_brm ( +bison(edge_weight(node_1_id, node_2_id)) ~ age_diff, +fit_edge, +df_dyadic, +num_draws=5, # Small sample size for demonstration purposes +refresh=0 +) +summary(fit_dyadic) +cv_samples <- extract_metric(fit_edge, "global_cv") +head(cv_samples) +plot(density(cv_samples)) +cv_samples <- extract_metric(fit_edge, "global_diameter") +head(cv_samples) +extract_metric(fit_edge, "global_diameter") +extract_metric(fit_edge, "global_clustering") +devtools::load_all(".") +extract_metric(fit_edge, "global_clustering") +extract_metric(fit_edge, "global_clustering") +devtools::load_all(".") +extract_metric(fit_edge, "global_clustering") +extract_metric(fit_edge, "global_clustering") +extract_metric(fit_edge, "global_clustering") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +extract_metric(fit_edge, "node_clustering[0.2]") +extract_metric(fit_edge, "node_degree[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_degree[0.2]") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "node_clustering[0.2]") +devtools::load_all(".") +extract_metric(fit_edge, "global_clustering[0.2]") +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary_conjugate", +priors=get_default_priors("binary_conjugate") +) +``` +sim_data <- simulate_bison_model("binary", aggregated = TRUE) +df <- sim_data$df_sim +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary_conjugate", +priors=get_default_priors("binary_conjugate") +) +dim(metrics) +dim(metrics) +dim(metrics) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +dim(metrics) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +dim(metrics) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +head(metrics) +head(metrics[, 1:3]) +head(metrics[, :6]) +head(metrics[, 1:6]) +head(metrics[:, 1:6]) # Show first +head(metrics) # Show first +metrics[1:6,1:4] # Preview first few samples and nodes +metrics[1:6,1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_strength", num_draws=10) +metrics[1:6,1:5] # Preview first few samples and nodes +metrics[1:6,1:5] # Preview first few samples and nodes +extract_metric(fit_edge, "node_betweenness") +metrics[1:6,1:5] # Preview first few samples and nodes +extract_metric(fit_edge, "node_betweenness") +metrics[1:6,1:5] # Preview first few samples and nodes +extract_metric(fit_edge, "node_betweenness") +metrics[1:6,1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_betweenness") +metrics[1:6,1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_eigen") +metrics[1:6,1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_degree[0.2]") +metrics[1:6,1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_closeness") +metrics[1:6, 1:5] # Preview first few samples and nodes +devtools::load_all(".") +metrics <- extract_metric(fit_edge, "node_clustering[0.2]") +metrics[1:6, 1:5] +metrics <- extract_metric(fit_edge, "node_cv") +metrics <- extract_metric(fit_edge, "global_cv") +metrics[1:6, 1:5] +metrics <- extract_metric(fit_edge, "global_cv") +metrics[1:6] +metrics <- extract_metric(fit_edge, "global_density") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[0.2]") +metrics[1:6] # Preview first few samples +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +tidy.opts=list(width.cutoff=80), +tidy=TRUE +) +library(bisonR) +library(dplyr) +sim_data <- simulate_bison_model("binary", aggregated = TRUE) +df <- sim_data$df_sim +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary_conjugate", +priors=get_default_priors("binary_conjugate") +) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and edges +metrics <- extract_metric(fit_edge, "node_strength", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_degree[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_eigen") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_betweenness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_closeness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_clustering[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "global_cv") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_density") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_std") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_diameter") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[0.2]") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[-0.5]") +metrics[1:6] # Preview first few samples +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +tidy.opts=list(width.cutoff=80), +tidy=TRUE +) +library(bisonR) +library(dplyr) +sim_data <- simulate_bison_model("binary", aggregated = TRUE) +df <- sim_data$df_sim +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary_conjugate", +priors=get_default_priors("binary_conjugate") +) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and edges +metrics <- extract_metric(fit_edge, "node_strength", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_degree[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_eigen") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_betweenness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_closeness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_clustering[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "global_cv") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_density") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_std") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_diameter") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[-0.5]") +metrics[1:6] # Preview first few samples +metrics # Preview first few samples +devtools::load_all(".") +devtools::load_all(".") +metrics <- extract_metric(fit_edge, "global_clustering[-0.5]") +metrics # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[0.2]") +metrics # Preview first few samples +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +tidy.opts=list(width.cutoff=80), +tidy=TRUE +) +library(bisonR) +library(dplyr) +sim_data <- simulate_bison_model("binary", aggregated = TRUE) +df <- sim_data$df_sim +fit_edge <- bison_model( +(event | duration) ~ dyad(node_1_id, node_2_id), +data=df, +model_type="binary_conjugate", +priors=get_default_priors("binary_conjugate") +) +metrics <- extract_metric(fit_edge, "edge_weight", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and edges +metrics <- extract_metric(fit_edge, "node_strength", num_draws=10) +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_degree[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_eigen") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_betweenness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_closeness") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "node_clustering[0.2]") +metrics[1:6, 1:5] # Preview first few samples and nodes +metrics <- extract_metric(fit_edge, "global_cv") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_density") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_std") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_diameter") +metrics[1:6] # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[0.2]") +metrics # Preview first few samples +metrics <- extract_metric(fit_edge, "global_clustering[0.2]") +metrics[1:6] # Preview first few samples +devtools::install() +devtools::install() +devtools::test() +devtools::test() +devtools::build_vignettes() +remotes::install_github("JHart96/bisonR") diff --git a/R/bison_model.R b/R/bison_model.R index 5a4cb9b..05b2f32 100644 --- a/R/bison_model.R +++ b/R/bison_model.R @@ -311,8 +311,8 @@ plot_network <- function(obj, ci=0.9, lwd=2, threshold=NULL) { threshold_ids <- edgelist[, 4] >= threshold } net <- igraph::graph_from_edgelist(as.matrix(edgelist[threshold_ids, 1:2]), directed=obj$directed) - lb <- edgelist[, 3] - ub <- edgelist[, 5] + lb <- edgelist[threshold_ids, 4] + ub <- edgelist[threshold_ids, 5] coords <- igraph::layout_nicely(net) igraph::plot.igraph(net, edge.width=lb * lwd, layout=coords, vertex.label.color="white", vertex.color=bison_colors[1], edge.color=rgb(0, 0, 0, 1), edge.arrow.size=0) igraph::plot.igraph(net, edge.width=ub * lwd, layout=coords, vertex.label.color="white", vertex.color=bison_colors[1], edge.color=rgb(0, 0, 0, 0.3), edge.arrow.size=0, add=TRUE)