run_swaglm.Rmd
library(swaglm)
# --------------------- generate from logistic regression with an intercept of one
z <- 1 + X %*% beta
pr <- 1 / (1 + exp(-z))
set.seed(12345)
y <- as.factor(rbinom(n, 1, pr))
y <- as.numeric(y) - 1
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
print(swag_obj)
#> SWAGLM results :
#> -----------------------------------------
#> Input matrix dimension: 2000 100
#> Number of explored models: 851
#> Number of dimensions explored: 15
swag_network <- compute_network(swag_obj)
plot(swag_network, scale_vertex = 0.05)
B <- 10
res_test <- swaglm_test(swag_obj, B = B)
print(res_test)
#> SWAGLM Test Results:
#> ----------------------
#> p-value (Eigen): 1
#> p-value (Freq): 0
swag_obj <- swaglm::swaglm(
X = X, y = y, p_max = p_max, family = stats::gaussian(),
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
print(swag_obj)
#> SWAGLM results :
#> -----------------------------------------
#> Input matrix dimension: 2000 100
#> Number of explored models: 837
#> Number of dimensions explored: 15
swag_network <- compute_network(swag_obj)
plot(swag_network, scale_vertex = 0.05)
res_test <- swaglm_test(swag_obj, B = B)
print(res_test)
#> SWAGLM Test Results:
#> ----------------------
#> p-value (Eigen): 0.8907
#> p-value (Freq): 2e-04
# Run swag procedure
swag_obj <- swaglm::swaglm(
X = X, y = y, p_max = p_max, family = stats::poisson(),
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
print(swag_obj)
#> SWAGLM results :
#> -----------------------------------------
#> Input matrix dimension: 2000 100
#> Number of explored models: 870
#> Number of dimensions explored: 15
swag_network <- compute_network(swag_obj)
plot(swag_network, scale_vertex = 0.05)
res_test <- swaglm_test(swag_obj, B = B)
print(res_test)
#> SWAGLM Test Results:
#> ----------------------
#> p-value (Eigen): 0.7324
#> p-value (Freq): 0.0288