Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions R/abe.R
Original file line number Diff line number Diff line change
Expand Up @@ -2563,12 +2563,12 @@ plot.abe<-function(x,type.plot=c("coefficients", "variables", "models", "stabili
if(type.plot == "stability"){

if(object$criterion == "alpha"){
alphas <- sort(object$misc$alpha)
alphas <- object$misc$alpha
if(!is.null(alpha)) alphas <- alpha
}
if(object$criterion == "AIC") alphas <- c("0.157")
if(object$criterion == "BIC") alphas <- c(1-pchisq(log(nrow(object$fit.global$x)), df=1))
taus <- sort(object$misc$tau)
taus <- object$misc$tau
if(!is.null(tau)) taus <- tau

if(length(alphas) > 1 & length(taus) == 1){
Expand All @@ -2589,9 +2589,15 @@ plot.abe<-function(x,type.plot=c("coefficients", "variables", "models", "stabili

if(length(alphas) <= 1) stop("Stability plots require more than one alpha value.")

data_longABE$tauLabel <- factor(
# save the labels as a factor with the desired order
# this makes sure the facet labels are in the right order in the plot
paste0("Tau = ", data_longABE$tau),
levels = paste0("Tau = ", taus)
)
p <- ggplot(data_longABE) +
geom_line(aes(x = alpha, y = value, col = variable), linewidth = 0.75) +
facet_wrap(~ paste0("Tau = ", tau)) +
facet_wrap(~ tauLabel) +
theme_bw() +
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
labs(x = expression(alpha), y = "Inclusion frequencies", col = "") +
Expand Down