Skip to content

Commit d6d5e0f

Browse files
author
Anthony Raborn
committed
ACO Plots now produce plots for change in betas. Package branch devel version upgraded to 0.4.3.
1 parent 3ddd3d2 commit d6d5e0f

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: ShortForm
22
Type: Package
33
Title: Automatic Short Form Creation
4-
Version: 0.4.2-9999
5-
Date: 2018-10-16
4+
Version: 0.4.3
5+
Date: 2019-8-7
66
Authors@R: c(person("Anthony", "Raborn", email = "anthony.w.raborn@gmail.com", role = c("aut", "cre")), person("Walter", "Leite", email = "Walter.Leite@coe.ufl.edu", role = "aut"))
77
Description: Performs automatic creation of short forms of scales with an
88
ant colony optimization algorithm and a Tabu search. As implemented in the

R/shortform_plots.R

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
#' Objects of classes \code{tabu} and \code{simulatedAnnealing} produce a
88
#' single plot which show the changes in the objective function across each
99
#' iteration of the algorithm. Objects of class \code{antcolony} can produce
10-
#' up to three plots which show the changes in the pheromone levels for each
10+
#' up to four plots which show the changes in the pheromone levels for each
1111
#' item, changes in the average standardized regression coefficients of the
12-
#' model, and changes in the amount of variance explained in the model across
13-
#' each iteration of the algorithm.
12+
#' model (gammas and betas), and changes in the amount of variance explained
13+
#' in the model across each iteration of the algorithm.
1414
#'
1515
#' These functions do not currently allow users to modify the resulting
1616
#' plots directly, but the objects produces are \pkg{ggplot2} objects which
1717
#' should allow for additional user customization.
1818
#'
1919
#' @param x An object with one of the following classes: \code{antcolony},
2020
#' \code{tabu}, or \code{simulatedAnnealing}.
21-
#' @param type A character string. One of "all", "pheromone", "gamma", or
21+
#' @param type A character string. One of "all", "pheromone", "gamma", "beta", or
2222
#' "variance". Matched literally. Only used with objects of class \code{antcolony}.
2323
#' @param ... Not used with the current S3 method implementation.
2424
#' @name plot
@@ -27,7 +27,7 @@
2727

2828
plot.antcolony <- function(x, type = "all", ...) {
2929
summary_results <- x[[2]]
30-
pheromone_plot = gamma_plot = variance_plot = NULL
30+
pheromone_plot = gamma_plot = beta_plot = variance_plot = NULL
3131
item_pheromone_names <-
3232
grep("Pheromone", names(summary_results), value = TRUE)
3333

@@ -87,6 +87,28 @@ plot.antcolony <- function(x, type = "all", ...) {
8787
)
8888
}
8989

90+
if (type %in% c("all", "beta")) {
91+
beta_plot <-
92+
ggplot2::ggplot(summary_results,
93+
ggplot2::aes_string(x = "run", y = "mean.beta")) +
94+
ggplot2::geom_smooth(fullrange = TRUE, se = FALSE, na.rm = T) +
95+
ggplot2::ylab(expression("Mean " * beta)) +
96+
ggplot2::ggtitle(expression("Smoothed Changes in Mean " * beta)) +
97+
ggplot2::geom_text(ggplot2::aes(label = ifelse(
98+
summary_results$run %in% c(1, max(summary_results$run)),
99+
round(summary_results$mean.beta, 3), ""
100+
)), vjust = 0, na.rm = T) +
101+
ggplot2::theme_bw() +
102+
ggplot2::theme(
103+
legend.position = "none",
104+
plot.title = ggplot2::element_text(
105+
size = 23,
106+
face = "bold",
107+
hjust = .5
108+
)
109+
)
110+
}
111+
90112
if (type %in% c("all", "variance")) {
91113
variance_plot <-
92114
ggplot2::ggplot(summary_results,
@@ -109,7 +131,8 @@ plot.antcolony <- function(x, type = "all", ...) {
109131
)
110132
}
111133

112-
plots <- list("Pheromone" = pheromone_plot, "Gamma" = gamma_plot, "Variance" = variance_plot)
134+
plots <- list("Pheromone" = pheromone_plot, "Gamma" = gamma_plot,
135+
"Beta" = beta_plot, "Variance" = variance_plot)
113136
return(plots)
114137

115138
}

man/plot.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)