Skip to content

Commit e1b7263

Browse files
authored
Merge pull request #36 from arcaldwell49/shiny-updates
Shiny updates
2 parents d8ca9f3 + 2046a77 commit e1b7263

File tree

90 files changed

+3016
-2029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3016
-2029
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ inst/doc
1313
.DS_Store
1414
NUL
1515
tests/testthat/Rplots.pdf
16+
.DS_Store

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Superpower
22
Title: Simulation-Based Power Analysis for Factorial Designs
3-
Version: 0.2.0
3+
Version: 0.2.1
44
Authors@R: c(person(given = "Aaron",
55
family = "Caldwell",
66
role = c("aut", "cre"),

NEWS.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ output: github_document
55

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

8+
# Superpower 0.2.1 -- "Jade"
9+
- Minor fix to the plot_power function
10+
- Major updates to the Shiny apps
11+
- Changes design input to a more friendly UI
12+
813
# Superpower 0.2.0 -- "Green Lantern"
914
- 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.
1015
- Added ANCOVA_analytic and ANCOVA_contrast which allow for power analyses for factorial designs and user specified contrasts.

NEWS.md

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,99 @@
11
NEWS
22
================
33

4-
Updated Tue Dec 07 2021
4+
Updated Mon Oct 10 2022
5+
6+
# Superpower 0.2.1 – “Jade”
7+
8+
- Minor fix to the plot_power function
9+
- Major updates to the Shiny apps
10+
- Changes design input to a more friendly UI
511

612
# Superpower 0.2.0 – “Green Lantern”
713

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

1723
# Superpower 0.1.2 – “Rex Splode”
1824

19-
- Minor fixes to power\_standardized\_alpha to keep Superpower on CRAN
25+
- Minor fixes to power_standardized_alpha to keep Superpower on CRAN
2026

2127
# Superpower 0.1.1 – “Black Canary”
2228

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

3541
# Superpower 0.1.0
3642

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

6470
# Superpower 0.0.5
6571

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

7682
# Superpower 0.0.4
7783

78-
- Added emmeans\_power function
84+
- Added emmeans_power function
7985
- Documentation added to the vignette
8086
- Small updates to the Shiny apps to fix typos
8187

8288
# Superpower 0.0.3
8389

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

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

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

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

103109
- Updated Shiny Apps
104110

105-
- Unequal n allowed for ANOVA\_power
111+
- Unequal n allowed for ANOVA_power
106112
- Added numeric input for alpha level (no longer slider)
107113
- Now includes emmeans options
108114
- kableExtra, emmeans, magrittr, and dplyr packages now needed to

R/ANOVA_power.R

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ ANOVA_power <- function(design_result,
161161
stop("alpha_level must be less than 1 and greater than zero")
162162
}
163163

164-
###############
165-
# 2. Read in Environment Data ----
166-
###############
164+
165+
# Read in Environment Data ----
166+
167167

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

@@ -198,9 +198,9 @@ ANOVA_power <- function(design_result,
198198
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
199199
n <- max(n) # now set n to max n for ANOVA_design function
200200

201-
###############
202-
# 3. Specify factors for formula ----
203-
###############
201+
202+
# Specify factors for formula ----
203+
204204

205205
frml1 <- design_result$frml1
206206
frml2 <- design_result$frml2
@@ -247,9 +247,9 @@ ANOVA_power <- function(design_result,
247247
if (run_manova == TRUE) {
248248
manova_result <- Anova_mlm_table(aov_result$Anova)
249249
}
250-
###############
250+
251251
# 5. Set up dataframe for simulation results
252-
###############
252+
253253

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

317317

318-
###############
319-
# 7. Start Simulation ----
320-
###############
318+
319+
# Start Simulation ----
320+
321321
#withProgress(message = 'Running simulations', value = 0, { #block outside of Shiny
322322
for (i in 1:nsims) { #for each simulated experiment
323323
#incProgress(1/nsims, detail = paste("Now running simulation", i, "out of",nsims,"simulations")) #Block outside of Shiny
@@ -420,13 +420,13 @@ ANOVA_power <- function(design_result,
420420
}
421421
#}) #close withProgress Block outside of Shiny
422422

423-
############################################
423+
424424
#End Simulation ###############
425425

426426

427-
###############
428-
# 8. Plot Results ----
429-
###############
427+
428+
# Plot Results ----
429+
430430

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

@@ -479,9 +479,9 @@ ANOVA_power <- function(design_result,
479479
facet_grid(variable ~ .) +
480480
labs(x = expression(p)) +
481481
theme_bw()
482-
###############
483-
# 9. Sumary of power and effect sizes of main effects and contrasts ----
484-
###############
482+
483+
# Sumary of power and effect sizes of main effects and contrasts ----
484+
485485

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

528-
#######################
528+
529529
# Return Results ----
530-
#######################
530+
531531
if (verbose == TRUE) {
532532
# The section below should be blocked out when in Shiny
533533
cat("Power and Effect sizes for ANOVA tests")

R/plot_power.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ plot_power <- function(design_result,
337337
plot_data_emm <- suppressMessages(melt(power_df_emm, id = c('n')))
338338

339339
#create data frame for annotation for desired power for emmeans
340-
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
340+
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
341341
colnames(annotate_df_emm) <- c("n", "power", "variable", "label") # add columns names
342-
annotate_df_emm$variable <- as.factor(levels(exact_result$emm_results$contrast)) #add variable label names
342+
annotate_df_emm$variable <- as.factor((exact_result$emm_results$contrast)) #add variable label names
343343
emm_n = annotate_df_emm
344344

345345
i<-1

0 commit comments

Comments
 (0)