Calculates the frequency that a variable is selected

apes_var_freq(list_result, ic = "BIC")

Arguments

list_result

a list of APES outputs

ic

Either "AIC" or "BIC"

Author

Kevin Wang

Examples

set.seed(10)
n = 100
p = 10
beta = c(1, -1, rep(0, p-2))
x = matrix(rnorm(n*p), ncol = p)
colnames(x) = paste0("X", 1:p)
y = rbinom(n = n, size = 1, prob = expit(x %*% beta))
data = data.frame(y, x)
model = glm(y ~ ., data = data, family = "binomial")

list_result = apes(model = model, n_boot = 20)
#> No variable size specified, searching all sizes from 1 to p... 

apes_var_freq(list_result = list_result, ic = "AIC")
#> # A tibble: 11 × 2
#>    variables  freq
#>    <fct>     <dbl>
#>  1 intercept  1   
#>  2 X2         1   
#>  3 X1         0.95
#>  4 X6         0.65
#>  5 X7         0.6 
#>  6 X8         0.6 
#>  7 X9         0.6 
#>  8 X10        0.6 
#>  9 X3         0.55
#> 10 X4         0.5 
#> 11 X5         0.4 
apes_var_freq(list_result = list_result, ic = "BIC")
#> # A tibble: 11 × 2
#>    variables  freq
#>    <fct>     <dbl>
#>  1 intercept  1   
#>  2 X2         0.85
#>  3 X1         0.8 
#>  4 X10        0.45
#>  5 X6         0.4 
#>  6 X9         0.4 
#>  7 X7         0.35
#>  8 X8         0.3 
#>  9 X5         0.25
#> 10 X4         0.2 
#> 11 X3         0.15