Skip to content

Commit

Permalink
Merge pull request #36 from arcaldwell49/shiny-updates
Browse files Browse the repository at this point in the history
Shiny updates
  • Loading branch information
arcaldwell49 authored Oct 10, 2022
2 parents d8ca9f3 + 2046a77 commit e1b7263
Show file tree
Hide file tree
Showing 90 changed files with 3,016 additions and 2,029 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ inst/doc
.DS_Store
NUL
tests/testthat/Rplots.pdf
.DS_Store
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Superpower
Title: Simulation-Based Power Analysis for Factorial Designs
Version: 0.2.0
Version: 0.2.1
Authors@R: c(person(given = "Aaron",
family = "Caldwell",
role = c("aut", "cre"),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ output: github_document

Updated `r format(Sys.time(), "%a %b %d %Y")`

# Superpower 0.2.1 -- "Jade"
- Minor fix to the plot_power function
- Major updates to the Shiny apps
- Changes design input to a more friendly UI

# Superpower 0.2.0 -- "Green Lantern"
- Added power_oneway_ancova & power_con_ancova to allow for a basic power analysis of an analysis of covariance (ANCOVA) for one-way, between group designs.
- Added ANCOVA_analytic and ANCOVA_contrast which allow for power analyses for factorial designs and user specified contrasts.
Expand Down
86 changes: 46 additions & 40 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,99 @@
NEWS
================

Updated Tue Dec 07 2021
Updated Mon Oct 10 2022

# Superpower 0.2.1 – “Jade”

- Minor fix to the plot_power function
- Major updates to the Shiny apps
- Changes design input to a more friendly UI

# Superpower 0.2.0 – “Green Lantern”

- Added power\_oneway\_ancova & power\_con\_ancova to allow for a
basic power analysis of an analysis of covariance (ANCOVA) for
one-way, between group designs.
- Added ANCOVA\_analytic and ANCOVA\_contrast which allow for power
- Added power_oneway_ancova & power_con_ancova to allow for a basic
power analysis of an analysis of covariance (ANCOVA) for one-way,
between group designs.
- Added ANCOVA_analytic and ANCOVA_contrast which allow for power
analyses for factorial designs and user specified contrasts.
- Added the label\_list argument to ANOVA\_design and ANCOVA\_analytic
- Added the label_list argument to ANOVA_design and ANCOVA_analytic
functions. Now labels can be assigned to factors and levels in a
more sane fashion using named lists.

# Superpower 0.1.2 – “Rex Splode”

- Minor fixes to power\_standardized\_alpha to keep Superpower on CRAN
- Minor fixes to power_standardized_alpha to keep Superpower on CRAN

# Superpower 0.1.1 – “Black Canary”

- Added morey\_plot functions.
- Added morey_plot functions.
- Plot the effect size (x-axis) at different sample sizes (facets)
and at different alpha levels (color).
- These plots are helpful in determining the sensitivity of
statistical tests (t-test and F-test) across a range of effect
sizes.
- Added confint method for ANOVA\_power produced objects
- Calculates confidence level for binomial proportion (\# of
- Added confint method for ANOVA_power produced objects
- Calculates confidence level for binomial proportion (# of
results that are below alpha level) confidence intervals
(Wilson, 1927)).
(Wilson, 1927).
- Minor changes to Shiny apps to fix glitches.

# Superpower 0.1.0

- Added ANOVA\_exact2 function as an extension of ANOVA\_exact
- Added ANOVA_exact2 function as an extension of ANOVA_exact
- Now functional across all sample sizes but does not return a
dataframe of afex aov object
- liberal\_lambda argument added: allows users to specify the type of
- liberal_lambda argument added: allows users to specify the type of
lambda calculations
- When liberal\_lambda = TRUE; lambda = cohen\_f^2 \* (num\_df +
den\_df + 1)
- When liberal\_lambda = FALSE; lambda = cohen\_f^2 \* den\_df
- When liberal_lambda = TRUE; lambda = cohen_f^2 \* (num_df +
den_df + 1)
- When liberal_lambda = FALSE; lambda = cohen_f^2 \* den_df
- Optimal alpha functions from JustifieR package added
- ANOVA\_compromise function added which allows a compromise power
- ANOVA_compromise function added which allows a compromise power
analysis to be performed for all comparisons in a design
- ANOVA\_design now returns as a class “design\_aov” with specific
print and plot methods see ?`design_aov-methods`
- generate\_cor\_matrix function is now a non-exported function
within the package (no longer contained within ANOVA\_design)
- All simulation functions ANOVA\_power, ANOVA\_exact, and
ANOVA\_exact2 now returns as a class “sim\_result” with specific
print and plot methods see ?`sim_result-methods`
- plot\_power now has reduced sample size limitations -Option to use
ANOVA\_exact2 (exact2 argument) improves functionality (not limited
- ANOVA_design now returns as a class “design_aov” with specific print
and plot methods see ?`design_aov-methods`
- generate_cor_matrix function is now a non-exported function
within the package (no longer contained within ANOVA_design)
- All simulation functions ANOVA_power, ANOVA_exact, and ANOVA_exact2
now returns as a class “sim_result” with specific print and plot
methods see ?`sim_result-methods`
- plot_power now has reduced sample size limitations -Option to use
ANOVA_exact2 (exact2 argument) improves functionality (not limited
to product of factors)
- Updated vignettes to include updated information on functions
- New vignette “Introduction to Justifying Alpha Levels”
- New Shiny App: justify
- Creates a UI for utilizing the ANOVA\_compromise function via
- Creates a UI for utilizing the ANOVA_compromise function via
Shiny

# Superpower 0.0.5

- Superpower\_options(“plot”) is now set to TRUE. Plots will, by
default, be printed -Easily reset with Superpower\_options(plot =
- Superpower_options(“plot”) is now set to TRUE. Plots will, by
default, be printed -Easily reset with Superpower_options(plot =
FALSE)
- plot\_power has new features -Plots now show desired power -min\_n
is now limited; smallest min\_n allowed is equal to the product of
the design (e.g., ’2b\*2b’ has a smallest min\_n of 4)
- Small update to plot\_power to fix minor error in original code
- plot_power has new features -Plots now show desired power -min_n is
now limited; smallest min_n allowed is equal to the product of the
design (e.g., ’2b\*2b’ has a smallest min_n of 4)
- Small update to plot_power to fix minor error in original code
-Error resulted in power estimates being \~0.1-0.5% off actual power
estimate

# Superpower 0.0.4

- Added emmeans\_power function
- Added emmeans_power function
- Documentation added to the vignette
- Small updates to the Shiny apps to fix typos

# Superpower 0.0.3

- Unequal sample size in the design is now permitted -Limited to the
ANOVA\_design and ANOVA\_power functions
ANOVA_design and ANOVA_power functions

- Added estimated marginal means comparisons using `emmeans` R
package.

- `emm = TRUE` in the ANOVA\_power, ANOVA\_exact, and plot\_power
- `emm = TRUE` in the ANOVA_power, ANOVA_exact, and plot_power
will result in emmeans being calculated
- Default is all pairwise comparisons but this can be modified
with `contrast_type` and `emm_comp` options
Expand All @@ -96,13 +102,13 @@ Updated Tue Dec 07 2021

- Options that have crossover between functions can now be set
globally for the package
- Includes: verbose, emm, emm\_model, contrast\_type,
alpha\_level, and plot
- These global options can be seen with Superpower\_options()
- Includes: verbose, emm, emm_model, contrast_type, alpha_level,
and plot
- These global options can be seen with Superpower_options()

- Updated Shiny Apps

- Unequal n allowed for ANOVA\_power
- Unequal n allowed for ANOVA_power
- Added numeric input for alpha level (no longer slider)
- Now includes emmeans options
- kableExtra, emmeans, magrittr, and dplyr packages now needed to
Expand Down
40 changes: 20 additions & 20 deletions R/ANOVA_power.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ ANOVA_power <- function(design_result,
stop("alpha_level must be less than 1 and greater than zero")
}

###############
# 2. Read in Environment Data ----
###############

# Read in Environment Data ----


design <- design_result$design #String used to specify the design

Expand Down Expand Up @@ -198,9 +198,9 @@ ANOVA_power <- function(design_result,
n_vec <- n # store vector n as n - this is because the code below uses n as a single number, so quick fix for legacy reasons
n <- max(n) # now set n to max n for ANOVA_design function

###############
# 3. Specify factors for formula ----
###############

# Specify factors for formula ----


frml1 <- design_result$frml1
frml2 <- design_result$frml2
Expand Down Expand Up @@ -247,9 +247,9 @@ ANOVA_power <- function(design_result,
if (run_manova == TRUE) {
manova_result <- Anova_mlm_table(aov_result$Anova)
}
###############

# 5. Set up dataframe for simulation results
###############


#How many possible planned comparisons are there (to store p and es)
possible_pc <- (((prod(
Expand Down Expand Up @@ -315,9 +315,9 @@ ANOVA_power <- function(design_result,
}


###############
# 7. Start Simulation ----
###############

# Start Simulation ----

#withProgress(message = 'Running simulations', value = 0, { #block outside of Shiny
for (i in 1:nsims) { #for each simulated experiment
#incProgress(1/nsims, detail = paste("Now running simulation", i, "out of",nsims,"simulations")) #Block outside of Shiny
Expand Down Expand Up @@ -420,13 +420,13 @@ ANOVA_power <- function(design_result,
}
#}) #close withProgress Block outside of Shiny

############################################

#End Simulation ###############


###############
# 8. Plot Results ----
###############

# Plot Results ----


# melt the data into a long format for plots in ggplot2

Expand Down Expand Up @@ -479,9 +479,9 @@ ANOVA_power <- function(design_result,
facet_grid(variable ~ .) +
labs(x = expression(p)) +
theme_bw()
###############
# 9. Sumary of power and effect sizes of main effects and contrasts ----
###############

# Sumary of power and effect sizes of main effects and contrasts ----


#Main effects and interactions from the ANOVA
power = as.data.frame(apply(as.matrix(sim_data[(1:(2 ^ factors - 1))]), 2,
Expand Down Expand Up @@ -525,9 +525,9 @@ ANOVA_power <- function(design_result,
names(manova_result) = c("power")
}

#######################

# Return Results ----
#######################

if (verbose == TRUE) {
# The section below should be blocked out when in Shiny
cat("Power and Effect sizes for ANOVA tests")
Expand Down
4 changes: 2 additions & 2 deletions R/plot_power.R
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ plot_power <- function(design_result,
plot_data_emm <- suppressMessages(melt(power_df_emm, id = c('n')))

#create data frame for annotation for desired power for emmeans
annotate_df_emm <- as.data.frame(matrix(0, ncol = 4, nrow = length(levels(exact_result$emm_results$contrast)))) #three rows, for N, power, and variable label
annotate_df_emm <- as.data.frame(matrix(0, ncol = 4, nrow = length((exact_result$emm_results$contrast)))) #three rows, for N, power, and variable label
colnames(annotate_df_emm) <- c("n", "power", "variable", "label") # add columns names
annotate_df_emm$variable <- as.factor(levels(exact_result$emm_results$contrast)) #add variable label names
annotate_df_emm$variable <- as.factor((exact_result$emm_results$contrast)) #add variable label names
emm_n = annotate_df_emm

i<-1
Expand Down
Loading

0 comments on commit e1b7263

Please sign in to comment.