View source: R/plot.boot_apes.R
plot.boot_apes | R Documentation |
boot_apes
This function is suitable for a list of bootstrap APES outputs. From each bootstrap run, APES stores log-likelihood for every model it considered. In this function, we then consider general information criterion (GIC) of the form -2*logLike + penalty * modeSize. For each penalty and each bootstrap run, we apply this GIC to find a model of the optimal fit, and then look at which variables are selected in that model. The frequency of a variable selected across different penalties are then avaraged across all bootstrap runs.
This function displays the same information as plot_vi, but in a tile plot format.
## S3 method for class 'boot_apes'
plot(x, type = c("vip_tile", "vip", "path", "ma"), max_vars = NULL, ...)
plot_boot_apes_ma(x, order = "BIC", max_vars = NULL)
plot_boot_apes_path(x, order = "BIC")
plot_boot_apes_vip(x, max_vars = NULL)
plot_boot_apes_vip_tile(x, order = "median", categorical = FALSE)
x |
An object of class |
type |
Type of plot:
|
max_vars |
Maximum number of variables to label. Default to NULL which plots all variables. |
... |
Additional parameters. Some options are:
|
order |
The ordering of variables. Either "median", "AIC" or "BIC" |
categorical |
If categorised colour scheme should be used. Default to FALSE. |
A ggplot output corresponding to the select plotting type.
A ggplot. From each bootstrap run, APES stores coefficient values averaged across all models considered. As we have multiple bootstrapped APES output, we can cummulatively average these model averaged coefficient values across all bootstrap runs. On the final plot, we should be able to see variables of non-zero coefficients show up distinctly away from zero.
A ggplot of AIC/BIC path plot. Each curve is one bootstrapped APES run.
a variable inclusion plot in ggplot format. An attribute of the name plotdf is a tibble with all the necessary values to plot a variable inclusion plot
A list.
apes_mle_beta_binary_plotdf
a tibble with all the necessary values to plot a tile variable inclusion plot
var_tile_plot
a ggplot with continuous colouring
var_tile_plot_category
a ggplot with discrete colouring
Kevin Wang
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")
boot_result = apes(model = model, n_boot = 20)
plot(boot_result, type = "vip_tile")
plot(boot_result, type = "vip")
plot(boot_result, type = "path")
plot(boot_result, type = "ma")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.