Visualizes a SWAG network with discretized vertex size, optional edge width scaling, and edge coloring based on a correlation matrix.

# S3 method for class 'swaglm_network'
plot(x, bins = 5, scale_edge = NULL, size_range = c(8, 30), ...)

Arguments

x

An object of class swaglm_network

bins

Number of bins for vertex size discretization (default = 5)

scale_edge

Logical; whether to scale the edge width

size_range

A numeric vector of length 2 specifying the range of node sizes.

...

Additional arguments passed to igraph::plot

Value

None.

Examples

set.seed(12345)
n <- 2000
p <- 100

# create design matrix and vector of coefficients
Sigma <- diag(rep(1/p, p))
X <- MASS::mvrnorm(n = n, mu = rep(0, p), Sigma = Sigma)
beta = c(-15,-10,5,10,15, rep(0,p-5))

# --------------------- generate from logistic regression with an intercept of one
z <- 1 + X%*%beta
pr <- 1/(1 + exp(-z))
y <- as.factor(rbinom(n, 1, pr))
y = as.numeric(y)-1

# define swag parameters
quantile_alpha = .15
p_max = 20
swag_obj = swaglm::swaglm(X=X, y = y, p_max = p_max, family = stats::binomial(), 
                          alpha = quantile_alpha, verbose = TRUE, seed = 123)
#> Completed models of dimension 1
#> Completed models of dimension 2
#> Completed models of dimension 3
#> Completed models of dimension 4
#> Completed models of dimension 5
#> Completed models of dimension 6
#> Completed models of dimension 7
#> Completed models of dimension 8
#> Completed models of dimension 9
#> Completed models of dimension 10
#> Completed models of dimension 11
#> Completed models of dimension 12
#> Completed models of dimension 13
#> Completed models of dimension 14
#> Completed models of dimension 15
names(swag_obj)
#>  [1] "lst_estimated_beta"        "lst_p_value"              
#>  [3] "lst_AIC"                   "lst_var_mat"              
#>  [5] "lst_selected_models"       "lst_index_selected_models"
#>  [7] "y"                         "X"                        
#>  [9] "p_max"                     "alpha"                    
#> [11] "family"                    "method"                   
swag_network = swaglm::compute_network(swag_obj)
names(swag_network)
#> [1] "g"                "models"           "g_simplified_obs"
plot(swag_network)