├── .DS_Store ├── .Rbuildignore ├── .covrignore ├── .github ├── .gitignore ├── FUNDING.yml └── workflows │ ├── R-CMD-check.yaml │ ├── pkgdown.yaml │ └── test-coverage.yaml ├── .gitignore ├── .travis.yml ├── CRAN-RELEASE ├── CRAN-SUBMISSION ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.Rmd ├── NEWS.md ├── R ├── ANCOVA_analytic.R ├── ANCOVA_contrast.R ├── ANCOVA_factorial_power.R ├── ANOVA_compromise.R ├── ANOVA_design.R ├── ANOVA_exact.R ├── ANOVA_power.R ├── Anova_mlm_table.R ├── Superpower_options.R ├── alpha_standardized.R ├── ancova_helper_functions.R ├── effect_sizes.R ├── emmeans_power.R ├── exact_extrapolate_functions.R ├── generate_cor_matrix.R ├── globals.R ├── manova_functions.R ├── methods.ancova_power.R ├── methods.design_aov.R ├── methods.opt_alpha.R ├── methods.sim_result.R ├── minimize_balance_alpha.R ├── misc_functions.R ├── morey_plots.R ├── mu_from_ES.R ├── oneway_ancova.R ├── p_standardized.R ├── plot_power.R ├── power_ftest.R ├── power_oneway_between.R ├── power_oneway_within.R ├── power_standardized_alpha.R ├── power_threeway_between.R ├── power_twoway_between.R └── zzz.R ├── README.Rmd ├── README.md ├── README_files ├── figure-gfm │ ├── mean-plot-1.png │ ├── sim-interaction-2-1.png │ ├── sim-interaction-2-2.png │ ├── sim-interaction-2-3.png │ ├── sim-interaction-3-1.png │ ├── sim-interaction-3-2.png │ ├── unnamed-chunk-1-1.png │ ├── unnamed-chunk-10-1.png │ ├── unnamed-chunk-11-1.png │ ├── unnamed-chunk-11-2.png │ ├── unnamed-chunk-11-3.png │ ├── unnamed-chunk-11-4.png │ ├── unnamed-chunk-12-1.png │ ├── unnamed-chunk-13-1.png │ ├── unnamed-chunk-14-1.png │ ├── unnamed-chunk-15-1.png │ ├── unnamed-chunk-16-1.png │ ├── unnamed-chunk-17-1.png │ ├── unnamed-chunk-18-1.png │ ├── unnamed-chunk-19-1.png │ ├── unnamed-chunk-2-1.png │ ├── unnamed-chunk-20-1.png │ ├── unnamed-chunk-22-1.png │ ├── unnamed-chunk-23-1.png │ ├── unnamed-chunk-24-1.png │ ├── unnamed-chunk-25-1.png │ ├── unnamed-chunk-26-1.png │ ├── unnamed-chunk-27-1.png │ ├── unnamed-chunk-28-1.png │ ├── unnamed-chunk-29-1.png │ ├── unnamed-chunk-3-1.png │ ├── unnamed-chunk-30-1.png │ ├── unnamed-chunk-31-1.png │ ├── unnamed-chunk-32-1.png │ ├── unnamed-chunk-33-1.png │ ├── unnamed-chunk-34-1.png │ ├── unnamed-chunk-35-1.png │ ├── unnamed-chunk-36-1.png │ ├── unnamed-chunk-37-1.png │ ├── unnamed-chunk-38-1.png │ ├── unnamed-chunk-39-1.png │ ├── unnamed-chunk-4-1.png │ ├── unnamed-chunk-40-1.png │ ├── unnamed-chunk-5-1.png │ ├── unnamed-chunk-6-1.png │ ├── unnamed-chunk-7-1.png │ ├── unnamed-chunk-8-1.png │ └── unnamed-chunk-9-1.png └── figure-latex │ ├── mean-plot-1.pdf │ ├── sim-interaction-2-1.pdf │ ├── sim-interaction-2-2.pdf │ ├── sim-interaction-2-3.pdf │ ├── sim-interaction-3-1.pdf │ ├── sim-interaction-3-2.pdf │ ├── unnamed-chunk-1-1.pdf │ ├── unnamed-chunk-11-1.pdf │ ├── unnamed-chunk-11-2.pdf │ ├── unnamed-chunk-11-3.pdf │ ├── unnamed-chunk-11-4.pdf │ ├── unnamed-chunk-12-1.pdf │ ├── unnamed-chunk-19-1.pdf │ ├── unnamed-chunk-20-1.pdf │ ├── unnamed-chunk-22-1.pdf │ ├── unnamed-chunk-26-1.pdf │ ├── unnamed-chunk-28-1.pdf │ ├── unnamed-chunk-29-1.pdf │ ├── unnamed-chunk-32-1.pdf │ ├── unnamed-chunk-4-1.pdf │ ├── unnamed-chunk-6-1.pdf │ ├── unnamed-chunk-7-1.pdf │ └── unnamed-chunk-8-1.pdf ├── Shiny ├── Justify │ ├── app.R │ ├── report.Rmd │ └── rsconnect │ │ └── shinyapps.io │ │ └── arcaldwell49 │ │ └── justify.dcf ├── anova-exact │ ├── app.R │ ├── report.Rmd │ └── rsconnect │ │ └── shinyapps.io │ │ └── arcaldwell49 │ │ └── anova-exact.dcf ├── anova-power │ ├── app.R │ ├── report.Rmd │ └── rsconnect │ │ └── shinyapps.io │ │ └── arcaldwell49 │ │ └── anova-power.dcf └── morey_plots │ ├── app.R │ └── rsconnect │ └── shinyapps.io │ └── arcaldwell49 │ └── morey_plots.dcf ├── Sticker ├── AVENGEANCE.ttf ├── Marvel-Regular.ttf ├── Super.png ├── Superpower.png ├── Superpower2.PNG ├── Superpower2_v2.PNG ├── authors.png ├── justiceleague.ttf ├── letters.png ├── script.R ├── superman style 2.png ├── superman style 3.png └── superman style.png ├── Superpower.Rproj ├── Validation ├── ANCOVA_oneway_sims.Rmd ├── ANCOVA_oneway_sims.md ├── ANCOVA_threeway_sims.Rmd ├── ANCOVA_twoway_sims.Rmd ├── ANCOVA_twoway_sims.md └── ANCOVA_twoway_sims_files │ └── figure-gfm │ ├── unnamed-chunk-2-1.png │ └── unnamed-chunk-4-1.png ├── _pkgdown.yml ├── cran-comments.md ├── docs ├── 404.html ├── LICENSE-text.html ├── LICENSE.html ├── Superpower2.PNG ├── articles │ ├── ANCOVAs.html │ ├── ANCOVAs_files │ │ ├── figure-html │ │ │ ├── unnamed-chunk-6-1.png │ │ │ └── unnamed-chunk-7-1.png │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── compromise_power.html │ ├── compromise_power_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── figure-html │ │ │ ├── comp_plots-1.png │ │ │ ├── comp_plots-2.png │ │ │ ├── comp_plots-3.png │ │ │ ├── unnamed-chunk-1-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ └── unnamed-chunk-9-1.png │ │ ├── header-attrs-2.11 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.7 │ │ │ └── header-attrs.js │ ├── emmeans_power.html │ ├── emmeans_power_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── figure-html │ │ │ └── unnamed-chunk-2-1.png │ │ ├── header-attrs-2.11 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.7 │ │ │ └── header-attrs.js │ ├── index.html │ ├── intro_to_superpower.html │ ├── intro_to_superpower_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── figure-html │ │ │ ├── morey1-1.png │ │ │ ├── morey2-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-15-1.png │ │ │ ├── unnamed-chunk-16-1.png │ │ │ ├── unnamed-chunk-17-1.png │ │ │ ├── unnamed-chunk-18-1.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-20-1.png │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ └── unnamed-chunk-8-1.png │ │ ├── header-attrs-2.11 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.7 │ │ │ └── header-attrs.js │ ├── more_anova_designs.html │ ├── more_anova_designs_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── figure-html │ │ │ ├── mean-plot-1.png │ │ │ ├── unnamed-chunk-10-1.png │ │ │ ├── unnamed-chunk-11-1.png │ │ │ ├── unnamed-chunk-13-1.png │ │ │ ├── unnamed-chunk-17-1.png │ │ │ ├── unnamed-chunk-19-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ ├── unnamed-chunk-20-1.png │ │ │ └── unnamed-chunk-24-1.png │ │ ├── header-attrs-2.11 │ │ │ └── header-attrs.js │ │ └── header-attrs-2.7 │ │ │ └── header-attrs.js │ ├── screenshots │ │ ├── PS2000.gif │ │ ├── gpower_1.png │ │ ├── gpower_10.png │ │ ├── gpower_11.png │ │ ├── gpower_12.png │ │ ├── gpower_14.png │ │ ├── gpower_5.png │ │ ├── gpower_6.png │ │ └── gpower_9.png │ └── sim_data │ │ └── vig_1_plot.png ├── authors.html ├── authors.png ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── index.html ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── ANCOVA_analytic.html │ ├── ANCOVA_contrast.html │ ├── ANOVA_compromise.html │ ├── ANOVA_design-1.png │ ├── ANOVA_design.html │ ├── ANOVA_exact-1.png │ ├── ANOVA_exact.html │ ├── ANOVA_power.html │ ├── Rplot001.png │ ├── Superpower_options.html │ ├── alpha_standardized.html │ ├── ancova_power-methods.html │ ├── design_aov-methods.html │ ├── emmeans_power.html │ ├── figures │ │ ├── Superpower2.PNG │ │ └── authors.png │ ├── index.html │ ├── morey_plot.html │ ├── mu_from_ES.html │ ├── opt_alpha-methods.html │ ├── optimal_alpha-1.png │ ├── optimal_alpha.html │ ├── p_standardized.html │ ├── plot_power.html │ ├── power.ftest.html │ ├── power_oneway_ancova.html │ ├── power_oneway_between-1.png │ ├── power_oneway_between.html │ ├── power_oneway_within-1.png │ ├── power_oneway_within.html │ ├── power_standardized_alpha.html │ ├── power_threeway_between-1.png │ ├── power_threeway_between.html │ ├── power_twoway_between-1.png │ ├── power_twoway_between.html │ └── sim_result-methods.html └── sitemap.xml ├── index.html ├── index.md ├── inst ├── CITATION └── WORDLIST ├── jamovi ├── 0000.yaml ├── jmvpower.a.yaml ├── jmvpower.r.yaml ├── jmvpower.u.yaml └── js │ ├── css.js │ └── main.js ├── man ├── ANCOVA_analytic.Rd ├── ANCOVA_contrast.Rd ├── ANOVA_compromise.Rd ├── ANOVA_design.Rd ├── ANOVA_exact.Rd ├── ANOVA_power.Rd ├── Superpower_options.Rd ├── alpha_standardized.Rd ├── ancova_power-methods.Rd ├── design_aov-methods.Rd ├── emmeans_power.Rd ├── figures │ ├── Superpower2.PNG │ └── authors.png ├── morey_plot.Rd ├── mu_from_ES.Rd ├── opt_alpha-methods.Rd ├── optimal_alpha.Rd ├── p_standardized.Rd ├── plot_power.Rd ├── power.ftest.Rd ├── power_oneway_ancova.Rd ├── power_oneway_between.Rd ├── power_oneway_within.Rd ├── power_standardized_alpha.Rd ├── power_threeway_between.Rd ├── power_twoway_between.Rd └── sim_result-methods.Rd ├── mess ├── ANOVA_exact_dev.R ├── build and check package script.R ├── emm_exact.R ├── jmvpower.b.R ├── jmvpower.h.R ├── old_design_function.R ├── old_functions │ ├── plot_power_2x2_within.R │ ├── plot_power_oneway_between.R │ ├── plot_power_oneway_within.R │ ├── plot_power_twoway_between.R │ ├── power_2x2_within.R │ ├── power_2x2_within_2.R │ ├── power_twoway_within_2.R │ ├── test-plot_power_2x2_within.R │ ├── test-plot_power_oneway_between.R │ ├── test-plot_power_oneway_within.R │ ├── test-plot_power_twoway_between.R │ └── test-power_2x2_within.R ├── simple_ANCOVA.R └── try_out.R ├── tests ├── spelling.R ├── testthat.R └── testthat │ ├── test-ANOVA_compromise.R │ ├── test-ancova_analytic.R │ ├── test-anova_design.R │ ├── test-anova_exact.R │ ├── test-anova_power.R │ ├── test-emmeans_power.R │ ├── test-justifieR.R │ ├── test-morey.R │ ├── test-mu_from_ES.R │ ├── test-plot_power.R │ ├── test-power_oneway_ancova.R │ ├── test-power_oneway_between.R │ ├── test-power_oneway_within.R │ ├── test-power_threeway_between.R │ ├── test-power_twoway_between.R │ ├── test-powerftest.R │ └── test_sim_cor.R └── vignettes ├── .gitignore ├── ANCOVAs.Rmd ├── compromise_power.Rmd ├── emmeans_power.Rmd ├── intro_to_superpower.Rmd ├── more_anova_designs.Rmd ├── refs.json ├── screenshots ├── PS2000.gif ├── gpower_1.png ├── gpower_10.png ├── gpower_11.png ├── gpower_12.png ├── gpower_14.png ├── gpower_5.png ├── gpower_6.png └── gpower_9.png └── sim_data ├── power_result_cross_40.rds ├── power_result_cross_80.rds ├── power_result_ordinal.rds ├── power_result_vig_1.rds ├── power_result_vig_2.rds ├── power_result_vig_3.rds ├── power_result_vig_4.rds └── vig_1_plot.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/.DS_Store -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^Meta$ 2 | ^mess$ 3 | ^doc$ 4 | ^README_files$ 5 | ^README.html$ 6 | ^LICENSE\.md$ 7 | ^superpower\.Rproj$ 8 | ^.travis.yml$ 9 | ^\.Rproj\.user$ 10 | ^codecov\.yml$ 11 | ^Shiny$ 12 | ^Sticker$ 13 | ^jamovi$ 14 | ^build/js$ 15 | ^temp$ 16 | ^.*\.jmo$ 17 | ^Validation$ 18 | ^NEWS\.Rmd$ 19 | ^jmvpower$ 20 | ^ANCOVA$ 21 | ^R/data_generation\.R$ 22 | ^R/jmvpower\.b\.R$ 23 | ^R/jmvpower\.h\.R$ 24 | ^simple_ANCOVA\.R$ 25 | ^R/simple_ANCOVA\.R$ 26 | ^tests/testthat/test-simple_ANCOVA\.R$ 27 | ^README\.Rmd$ 28 | ^CRAN-RELEASE$ 29 | ^\.RData$ 30 | ^\.Rhistory$ 31 | ^cran-comments\.md$ 32 | ^.covrignore$ 33 | 34 | ^_pkgdown\.yml$ 35 | ^docs$ 36 | ^pkgdown$ 37 | ^index\.Rmd$ 38 | ^index\.md$ 39 | ^index\.html$ 40 | ^\.github$ 41 | ^CRAN-SUBMISSION$ 42 | -------------------------------------------------------------------------------- /.covrignore: -------------------------------------------------------------------------------- 1 | R/zzz.R 2 | R/Superpower_options.R 3 | R/jmvpower.b.R 4 | R/jmvpower.h.R 5 | R/data_generation.R 6 | R/simple_ANCOVA.R 7 | R/manova_functions.R 8 | R/generate_cor_matrix.R -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: arcaldwell49 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macOS-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | #- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | #- {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: rcmdcheck 45 | 46 | - uses: r-lib/actions/check-r-package@v2 47 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown.yaml 13 | 14 | permissions: read-all 15 | 16 | jobs: 17 | pkgdown: 18 | runs-on: ubuntu-latest 19 | # Only restrict concurrency for non-PR jobs 20 | concurrency: 21 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 22 | env: 23 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 24 | permissions: 25 | contents: write 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - uses: r-lib/actions/setup-pandoc@v2 30 | 31 | - uses: r-lib/actions/setup-r@v2 32 | with: 33 | use-public-rspm: true 34 | 35 | - uses: r-lib/actions/setup-r-dependencies@v2 36 | with: 37 | extra-packages: any::pkgdown, local::. 38 | needs: website 39 | 40 | - uses: r-lib/actions/setup-tinytex@v2 41 | 42 | - name: Build site 43 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 44 | shell: Rscript {0} 45 | 46 | - name: Deploy to GitHub pages 🚀 47 | if: github.event_name != 'pull_request' 48 | uses: JamesIves/github-pages-deploy-action@v4.5.0 49 | with: 50 | clean: false 51 | branch: gh-pages 52 | folder: docs 53 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - uses: r-lib/actions/setup-r-dependencies@v2 25 | with: 26 | extra-packages: covr 27 | 28 | - name: Test coverage 29 | run: covr::codecov() 30 | shell: Rscript {0} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | Meta 3 | .Rhistory 4 | doc 5 | build/js 6 | build/R 7 | temp 8 | *.jmo 9 | *.RData 10 | .RData 11 | inst/doc 12 | 13 | *.DS_Store 14 | NUL 15 | tests/testthat/Rplots.pdf 16 | .DS_Store 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | cache: packages 3 | r_packages: 4 | - covr 5 | after_success: 6 | - Rscript -e 'library(covr); codecov()' -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2021-05-24. 2 | Once it is accepted, delete this file and tag the release (commit 2fc666c). 3 | -------------------------------------------------------------------------------- /CRAN-SUBMISSION: -------------------------------------------------------------------------------- 1 | Version: 0.2.0 2 | Date: 2022-05-16 17:38:06 UTC 3 | SHA: 83bed792b4c3bed761463fa3616599ef1d48dff3 4 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: Superpower 2 | Title: Simulation-Based Power Analysis for Factorial Designs 3 | Version: 0.2.3 4 | Authors@R: c(person(given = "Aaron", 5 | family = "Caldwell", 6 | role = c("aut", "cre"), 7 | email = "arcaldwell49@gmail.com"), 8 | person(given = "Daniel",family = "Lakens", 9 | role = c("aut"), 10 | email = "D.Lakens@tue.nl"), 11 | person(given = "Lisa", 12 | family = "DeBruine", 13 | role = c("ctb"), 14 | email = "debruine@gmail.com"), 15 | person(given = "Jonathon", 16 | family = "Love", 17 | role = c("ctb"), 18 | email = "jon@thon.cc"), 19 | person(given = "Frederik", 20 | family = "Aust", 21 | email = "frederik.aust@uni-koeln.de", 22 | role = c("ctb"), 23 | comment = c(ORCID = "0000-0003-4900-788X"))) 24 | Description: Functions to perform simulations of ANOVA designs of up to three factors. Calculates the observed power and average observed effect size for all main effects and interactions in the ANOVA, and all simple comparisons between conditions. Includes functions for analytic power calculations and additional helper functions that compute effect sizes for ANOVA designs, observed error rates in the simulations, and functions to plot power curves. Please see Lakens, D., & Caldwell, A. R. (2021). "Simulation-Based Power Analysis for Factorial Analysis of Variance Designs". . 25 | URL: https://aaroncaldwell.us/SuperpowerBook/ 26 | BugReports: https://github.com/arcaldwell49/Superpower/issues 27 | License: MIT + file LICENSE 28 | Encoding: UTF-8 29 | RoxygenNote: 7.3.2 30 | Imports: 31 | MASS, 32 | afex, 33 | emmeans, 34 | ggplot2, 35 | reshape2, 36 | stats, 37 | dplyr, 38 | magrittr, 39 | tidyselect, 40 | tidyr 41 | Suggests: 42 | knitr, 43 | rmarkdown, 44 | pwr, 45 | testthat, 46 | covr, 47 | jmvcore, 48 | spelling 49 | VignetteBuilder: 50 | knitr 51 | Language: en-US 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: Daniel Lakens and Aaron R. Caldwell 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2021 Daniel Lakens and Aaron R. Caldwell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(confint,sim_result) 4 | S3method(emmeans_power,data.frame) 5 | S3method(emmeans_power,emmGrid) 6 | S3method(emmeans_power,summary_em) 7 | S3method(plot,ancova_power) 8 | S3method(plot,design_aov) 9 | S3method(plot,opt_alpha) 10 | S3method(plot,sim_result) 11 | S3method(print,ancova_power) 12 | S3method(print,design_aov) 13 | S3method(print,opt_alpha) 14 | S3method(print,sim_result) 15 | export(ANCOVA_analytic) 16 | export(ANCOVA_contrast) 17 | export(ANOVA_compromise) 18 | export(ANOVA_design) 19 | export(ANOVA_exact) 20 | export(ANOVA_exact2) 21 | export(ANOVA_power) 22 | export(Superpower_options) 23 | export(alpha_standardized) 24 | export(emmeans_power) 25 | export(morey_plot.ftest) 26 | export(morey_plot.ttest) 27 | export(mu_from_ES) 28 | export(optimal_alpha) 29 | export(p_standardized) 30 | export(plot_power) 31 | export(power.ftest) 32 | export(power_oneway_ancova) 33 | export(power_oneway_between) 34 | export(power_oneway_within) 35 | export(power_standardized_alpha) 36 | export(power_threeway_between) 37 | export(power_twoway_between) 38 | import(emmeans) 39 | import(ggplot2) 40 | importFrom(MASS,mvrnorm) 41 | importFrom(afex,aov_car) 42 | importFrom(dplyr,everything) 43 | importFrom(dplyr,mutate) 44 | importFrom(dplyr,select) 45 | importFrom(ggplot2,geom_line) 46 | importFrom(ggplot2,geom_point) 47 | importFrom(ggplot2,ggplot) 48 | importFrom(ggplot2,scale_x_continuous) 49 | importFrom(ggplot2,scale_y_continuous) 50 | importFrom(ggplot2,theme_minimal) 51 | importFrom(grDevices,colorRampPalette) 52 | importFrom(graphics,pairs) 53 | importFrom(magrittr,"%>%") 54 | importFrom(magrittr,'%>%') 55 | importFrom(reshape2,melt) 56 | importFrom(stats,as.formula) 57 | importFrom(stats,contr.sum) 58 | importFrom(stats,contrasts) 59 | importFrom(stats,dbeta) 60 | importFrom(stats,df) 61 | importFrom(stats,dt) 62 | importFrom(stats,median) 63 | importFrom(stats,model.matrix) 64 | importFrom(stats,optim) 65 | importFrom(stats,optimize) 66 | importFrom(stats,p.adjust) 67 | importFrom(stats,pf) 68 | importFrom(stats,pnorm) 69 | importFrom(stats,power) 70 | importFrom(stats,power.t.test) 71 | importFrom(stats,pt) 72 | importFrom(stats,qf) 73 | importFrom(stats,qnorm) 74 | importFrom(stats,qt) 75 | importFrom(stats,qtukey) 76 | importFrom(stats,sd) 77 | importFrom(stats,terms) 78 | importFrom(stats,uniroot) 79 | importFrom(tidyr,expand_grid) 80 | importFrom(tidyselect,matches) 81 | importFrom(utils,combn) 82 | -------------------------------------------------------------------------------- /R/ANCOVA_factorial_power.R: -------------------------------------------------------------------------------- 1 | pow_anc_meth = function(cmat, 2 | mu, # Vector of Group Means 3 | nvec, # Group Sample Sizes 4 | n_cov, # Number of Covariates 5 | r2, # Coefficient of Determination 6 | sd, # SD UNADJUSTED 7 | alpha_level # Alpha level 8 | ){ 9 | 10 | n_grp = length(mu) 11 | mu = mu 12 | var_e = (sd^2*(1-r2)) 13 | 14 | numint <- 2000 15 | dd <- 1e-5 16 | coevec <- c(1, 17 | rep(c(4, 2), numint / 2 - 1), 18 | 4, 1) 19 | bl <- dd 20 | bu <- 1 - dd 21 | intl <- (bu - bl) / numint 22 | bvec <- bl + intl * (0:numint) 23 | cmu <- cmat %*% matrix(mu, n_grp, 1) 24 | # Derive other details 25 | num_df <- nrow(cmat) 26 | N_tot <- sum(nvec) 27 | qmat <- diag(N_tot / nvec) 28 | # Matrix multiplication to get lower case gamma squared (eq. 23 from Shieh) 29 | l_gamma2 <- 30 | t(cmu) %*% solve(cmat %*% qmat %*% t(cmat)) %*% cmu / var_e 31 | 32 | N_tot <- sum(nvec) 33 | den_df <- N_tot - n_grp - n_cov 34 | dfx <- den_df + 1 35 | b <- n_cov / dfx 36 | # Get critical F-statistic 37 | fcrit <- qf(1 - alpha_level, num_df, den_df) 38 | # Solution differs by number of covariates 39 | if (n_cov == 1) { 40 | tl <- qt(dd, dfx) 41 | tu <- qt(1 - dd, dfx) 42 | intl <- (tu - tl) / numint 43 | tvec <- tl + intl * (0:numint) 44 | wtpdf <- (intl / 3) * coevec * dt(tvec, dfx) 45 | 46 | pow <- sum(wtpdf * pf( 47 | fcrit, 48 | num_df, 49 | den_df, 50 | c(N_tot * l_gamma2) / (1 + b * tvec ^ 2), 51 | lower.tail = FALSE 52 | )) 53 | } 54 | else { 55 | wbpdf <- (intl / 3) * coevec * dbeta(bvec, dfx / 2, n_cov / 2) 56 | pow <- sum(wbpdf * pf(fcrit, 57 | num_df, 58 | den_df, 59 | c(N_tot * l_gamma2) * bvec, 60 | lower.tail = FALSE) 61 | ) 62 | } 63 | 64 | return(list(pow = pow, 65 | num_df = num_df, 66 | den_df = den_df, 67 | N_tot = N_tot, 68 | beta_level = 1-pow, 69 | alpha_level = alpha_level, 70 | cmat = cmat, 71 | mu = mu, 72 | nvec = nvec, 73 | n_cov = n_cov, 74 | r2 = r2, 75 | sd = sd)) 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /R/Anova_mlm_table.R: -------------------------------------------------------------------------------- 1 | # Function to create data frame of MANOVA results 2 | 3 | 4 | Anova_mlm_table <- function(x, ...) 5 | { 6 | test <- x$test 7 | repeated <- x$repeated 8 | ntests <- length(x$terms) 9 | tests <- matrix(NA, ntests, 4) 10 | if (!repeated) 11 | SSPE.qr <- qr(x$SSPE) 12 | for (term in 1:ntests) { 13 | eigs <- Re(eigen(qr.coef(if (repeated) 14 | qr(x$SSPE[[term]]) 15 | else 16 | SSPE.qr, 17 | x$SSP[[term]]), symmetric = FALSE)$values) 18 | tests[term, 1:4] <- switch( 19 | test, 20 | Pillai = Pillai(eigs, 21 | x$df[term], x$error.df), 22 | Wilks = Wilks(eigs, 23 | x$df[term], x$error.df), 24 | `Hotelling-Lawley` = 25 | HL(eigs, 26 | x$df[term], x$error.df), 27 | Roy = Roy(eigs, 28 | x$df[term], x$error.df) 29 | ) 30 | } 31 | ok <- tests[, 2] >= 0 & tests[, 3] > 0 & tests[, 4] > 0 32 | ok <- !is.na(ok) & ok 33 | tests <- cbind(x$df, tests, pf(tests[ok, 2], tests[ok, 3], 34 | tests[ok, 4], lower.tail = FALSE)) 35 | rownames(tests) <- x$terms 36 | colnames(tests) <- c("df", "test_stat", "approx_F", "num_Df", 37 | "den_Df", "p.value") 38 | tests <- structure(as.data.frame(tests), heading = paste("\nType ", 39 | x$type, if (repeated) 40 | " Repeated Measures", " MANOVA Tests: ", test, " test 41 | statistic", 42 | sep = ""), class = c("anova", "data.frame")) 43 | invisible(tests) 44 | } 45 | -------------------------------------------------------------------------------- /R/Superpower_options.R: -------------------------------------------------------------------------------- 1 | #' Set/get global Superpower options 2 | #' 3 | #' Global Superpower options are used, for example, by \code{\link{ANOVA_exact}} (et al.) 4 | #' and \code{\link{ANOVA_power}}. But can be changed in each functions directly using 5 | #' an argument (which has precedence over the global options). 6 | #' 7 | #' @param ... One of four: (1) nothing, then returns all options as a list; (2) 8 | #' a name of an option element, then returns its' value; (3) a name-value pair 9 | #' which sets the corresponding option to the new value (and returns nothing), 10 | #' (4) a list with option-value pairs which sets all the corresponding 11 | #' arguments. The example show all possible cases. 12 | #' 13 | #' @details The following arguments are currently set: 14 | #' \itemize{ 15 | #' \item \code{verbose} should verbose (printed results) be set to true? Default is \code{TRUE}. 16 | #' \item \code{emm} Option to perform analysis of estimated marginal means. Default is \code{FALSE}. 17 | #' \item \code{emm_model} Model type ("multivariate", or "univariate") for estimated marginal means. Default is \code{"multivariate"}. 18 | #' \item \code{contrast_type} The type of comparison for the estimated marginal means. Default is \code{"pairwise"}. See ?emmeans::'contrast-methods' for more details on acceptable methods. 19 | #' \item \code{plot} Option to automatically print plots. Default is \code{FALSE}. 20 | #' \item \code{alpha_level} Alpha level used to determine statistical significance. Default is .05. 21 | #' \item \code{correction} Option to set a correction for sphericity violations. Default is no correction. This can be set to "none", "GG" Greenhouse-Geisser, and "HF" Huynh-Feldt 22 | #' \item \code{liberal_lambda} Option to set a logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE. 23 | #' } 24 | #' 25 | #' @note All options are saved in the global R \code{\link{options}} with prefix 26 | #' \code{Superpower.} 27 | #' 28 | #' @return depends on input, see above. 29 | #' @export 30 | 31 | 32 | Superpower_options <- function(...) { 33 | dots <- list(...) 34 | #browser() 35 | if (length(dots) == 0) { # branch to get all Superpower options 36 | op <- options() 37 | Superpower_op <- op[grepl("^Superpower.", names(op))] 38 | names(Superpower_op) <- sub("^Superpower.", "", names(Superpower_op)) 39 | return(Superpower_op) 40 | } else if (is.list(dots[[1]])) { # set several Superpower options as a list: 41 | newop <- dots[[1]] 42 | names(newop) <- paste0("Superpower.", names(newop)) 43 | options(newop) 44 | } else if (!is.null(names(dots))) { 45 | newop <- dots 46 | names(newop) <- paste0("Superpower.", names(newop)) 47 | options(newop) 48 | } else if (is.null(names(dots))) { # get a single Superpower options 49 | if (length(dots) > 1) stop("Superpower_options() can only return the value of a single option.", call. = FALSE) 50 | return(getOption(paste0("Superpower.", unlist(dots)))) 51 | } else { 52 | warning("Unsupported command to Superpower_options(), nothing done.", call. = FALSE) 53 | } 54 | } -------------------------------------------------------------------------------- /R/alpha_standardized.R: -------------------------------------------------------------------------------- 1 | #' Compute standardized alpha level based on unstandardized alpha level and the number of observations N. 2 | #' @param alpha The unstandardized alpha level (e.g., 0.05), independent of the sample size. 3 | #' @param N The number of observations (e.g., the sample size) in the dataset 4 | #' @param standardize_N The number of observations (e.g., the sample size) you want to use to standardize the alpha level for. Defaults to 100 (base on Good, 1982). 5 | #' @examples 6 | #' ## Check it yields .05 for N = 100: 7 | #' alpha_standardized(alpha = 0.05, N = 100) 8 | #' ## Check it yields .05 for N = 200: 9 | #' alpha_standardized(alpha = 0.07071068, N = 200) 10 | #' ## Which alpha should we use with N = 200? 11 | #' alpha_standardized(alpha = 0.05, N = 200) 12 | #' ## You can change the standardization N, repeating the example above: 13 | #' alpha_standardized(alpha = 0.05, N = 100, standardize_N = 200) 14 | #' @section References: 15 | #' Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 16 | #' @export 17 | #' 18 | alpha_standardized <- function(alpha, N, standardize_N = 100){ 19 | alpha/sqrt(N/standardize_N) 20 | } 21 | -------------------------------------------------------------------------------- /R/generate_cor_matrix.R: -------------------------------------------------------------------------------- 1 | generate_cor_matrix <- function(vars = 3, cors = 0, mu = 0, sd = 1) { 2 | if (length(mu) == 1) { 3 | mu <- rep(mu, vars) 4 | } else if (length(mu) != vars) { 5 | stop("the length of mu must be 1 or vars"); 6 | } 7 | 8 | if (length(sd) == 1) { 9 | sd <- rep(sd, vars) 10 | } else if (length(sd) != vars) { 11 | stop("the length of sd must be 1 or vars"); 12 | } 13 | 14 | # correlation matrix 15 | if (inherits(cors, "numeric") & length(cors) == 1) { 16 | if (cors >=-1 & cors <=1) { 17 | cors = rep(cors, vars*(vars-1)/2) 18 | } else { 19 | stop("cors must be between -1 and 1") 20 | } 21 | } 22 | 23 | if (inherits(cors, "matrix")) { 24 | if (!is.numeric(cors)) { 25 | stop("cors matrix not numeric") 26 | } else if (dim(cors)[1] != vars || dim(cors)[2] != vars) { 27 | stop("cors matrix wrong dimensions") 28 | } else if (sum(cors == t(cors)) != (nrow(cors)^2)) { 29 | stop("cors matrix not symmetric") 30 | } else { 31 | cor_mat <- cors 32 | } 33 | } else if (length(cors) == vars*vars) { 34 | cor_mat <- matrix(cors, vars) 35 | } else if (length(cors) == vars*(vars-1)/2) { 36 | # generate full matrix from vector of upper right triangle 37 | 38 | cor_mat <- matrix(nrow=vars, ncol = vars) 39 | upcounter = 1 40 | lowcounter = 1 41 | for (col in 1:vars) { 42 | for (row in 1:vars) { 43 | if (row == col) { 44 | # diagonal 45 | cor_mat[row, col] = 1 46 | } else if (row > col) { 47 | # lower left triangle 48 | cor_mat[row, col] = cors[lowcounter] 49 | lowcounter <- lowcounter + 1 50 | } 51 | } 52 | } 53 | for (row in 1:vars) { 54 | for (col in 1:vars) { 55 | if (row < col) { 56 | # upper right triangle 57 | cor_mat[row, col] = cors[upcounter] 58 | upcounter <- upcounter + 1 59 | } 60 | } 61 | } 62 | } 63 | 64 | # check matrix is positive definite 65 | tol <- 1e-08 66 | ev <- eigen(cor_mat, only.values = TRUE)$values 67 | if (sum(ev < tol)) { 68 | stop("correlation matrix not positive definite") 69 | } 70 | 71 | return(cor_mat) 72 | } -------------------------------------------------------------------------------- /R/globals.R: -------------------------------------------------------------------------------- 1 | # Globals 2 | 3 | utils::globalVariables(c("monte_gen","exact_gen","lambda","cohen_f","contrasts<-")) -------------------------------------------------------------------------------- /R/manova_functions.R: -------------------------------------------------------------------------------- 1 | #functions for mlm table 2 | 3 | Roy <- function(eig, q, df.res) { 4 | p <- length(eig) 5 | test <- max(eig) 6 | tmp1 <- max(p, q) 7 | tmp2 <- df.res - tmp1 + q 8 | c(test, (tmp2 * test)/tmp1, tmp1, tmp2) 9 | } 10 | 11 | Wilks <- function(eig, q, df.res) 12 | { 13 | test <- prod(1/(1 + eig)) 14 | p <- length(eig) 15 | tmp1 <- df.res - 0.5 * (p - q + 1) 16 | tmp2 <- (p * q - 2)/4 17 | tmp3 <- p^2 + q^2 - 5 18 | tmp3 <- if (tmp3 > 0) 19 | sqrt(((p * q)^2 - 4)/tmp3) 20 | else 1 21 | c(test, ((test^(-1/tmp3) - 1) * (tmp1 * tmp3 - 2 * tmp2))/p/q, 22 | p * q, tmp1 * tmp3 - 2 * tmp2) 23 | } 24 | 25 | HL <- function(eig, q, df.res) 26 | { 27 | test <- sum(eig) 28 | p <- length(eig) 29 | m <- 0.5 * (abs(p - q) - 1) 30 | n <- 0.5 * (df.res - p - 1) 31 | s <- min(p, q) 32 | tmp1 <- 2 * m + s + 1 33 | tmp2 <- 2 * (s * n + 1) 34 | c(test, (tmp2 * test)/s/s/tmp1, s * tmp1, tmp2) 35 | } 36 | 37 | Pillai <- function(eig, q, df.res) 38 | { 39 | test <- sum(eig/(1 + eig)) 40 | p <- length(eig) 41 | s <- min(p, q) 42 | n <- 0.5 * (df.res - p - 1) 43 | m <- 0.5 * (abs(p - q) - 1) 44 | tmp1 <- 2 * m + s + 1 45 | tmp2 <- 2 * n + s + 1 46 | c(test, (tmp2/tmp1 * test)/(s - test), s * tmp1, s * tmp2) 47 | } -------------------------------------------------------------------------------- /R/methods.ancova_power.R: -------------------------------------------------------------------------------- 1 | #' Methods for ancova_power objects 2 | #' 3 | #' Methods defined for objects returned from the ANCOVA_analytic function. 4 | #' 5 | #' @param x object of class \code{ancova_power} as returned from one of the simulation functions in Superpower. 6 | #' @param ... further arguments passed through, see description of return value 7 | #' @return 8 | #' \describe{ 9 | #' \item{\code{print}}{Prints short summary of the simulation result} 10 | #' \item{\code{plot}}{Returns a meansplot of from the defined design} 11 | #' } 12 | #' @name ancova_power-methods 13 | 14 | 15 | ### methods for ancova_power 16 | 17 | #' @rdname ancova_power-methods 18 | #' @method print ancova_power 19 | #' @export 20 | 21 | print.ancova_power <- function(x,...){ 22 | 23 | if (!is.null(x$main_results)) { 24 | pow_tab1 = data.frame(`Total N`= x$main_results$N_tot, 25 | `Covariates`= x$main_results$n_cov, 26 | `r2`= x$main_results$r2, 27 | `Alpha Level`= x$main_results$alpha_level, 28 | `Beta Level`= x$main_results$beta_level, 29 | `Power` = x$main_results$power, 30 | check.names = FALSE) 31 | row.names(pow_tab1) = x$main_results$factor 32 | 33 | cat("Power Analysis Results for ANCOVA") 34 | cat("\n") 35 | print(pow_tab1, digits = 4) 36 | cat("\n") 37 | } 38 | if (!is.null(x$contrast_results)) { 39 | pow_tab2 = data.frame(`Total N`= x$contrast_results$N_tot, 40 | `Covariates`= x$contrast_results$n_cov, 41 | `r2`= x$contrast_results$r2, 42 | `Alpha Level`= x$contrast_results$alpha_level, 43 | `Beta Level`= x$contrast_results$beta_level, 44 | `Power` = x$contrast_results$power, 45 | check.names = FALSE) 46 | row.names(pow_tab2) = x$contrast_results$factor 47 | cat("Power Analysis Results for ANCOVA contrasts") 48 | cat("\n") 49 | print(pow_tab2, digits = 4) 50 | } 51 | 52 | 53 | } 54 | 55 | #' @rdname ancova_power-methods 56 | #' @method plot ancova_power 57 | #' @import ggplot2 58 | #' @export 59 | 60 | plot.ancova_power <- function(x,...){ 61 | if(is.null(x$design_params$design)){ 62 | stop("No plotting method when design is not provided.") 63 | } 64 | 65 | plot(ANOVA_design(design = x$design_params$design, 66 | n = 40, 67 | mu = x$design_params$mu, 68 | sd = x$design_params$sd, 69 | r = 0, 70 | label_list = x$design_params$label_list, 71 | plot = FALSE)) 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /R/methods.design_aov.R: -------------------------------------------------------------------------------- 1 | #' Methods for design_aov objects 2 | #' 3 | #' Methods defined for objects returned from the ANOVA_design functions. 4 | #' 5 | #' @param x object of class \code{design_aov} as returned from \code{ANOVA_design} 6 | #' @param ... further arguments passed through, see description of return value 7 | #' for details. 8 | #' \code{\link{ANOVA_design}}. 9 | #' @return 10 | #' \describe{ 11 | #' \item{\code{print}}{Prints short summary of the study design created from \code{ANOVA_design} function} 12 | #' \item{\code{plot}}{Returns \code{meansplot} from created from the \code{ANOVA_design} function} 13 | #' } 14 | #' 15 | #' @name design_aov-methods 16 | 17 | 18 | ### methods for design_aov (created by ANOVA_design) 19 | 20 | #' @rdname design_aov-methods 21 | #' @method print design_aov 22 | #' @export 23 | 24 | print.design_aov <- function(x,...){ 25 | cat("The design is specified as:",x$design) 26 | cat("\n") 27 | cat("Summary of means (mu) and standard deviations (SD)") 28 | cat("\n") 29 | print(x$meansplot$data) 30 | cat("\n") 31 | cat("Correlation Matrix") 32 | cat("\n") 33 | print(x$cor_mat) 34 | } 35 | 36 | #' @rdname design_aov-methods 37 | #' @method plot design_aov 38 | #' @import ggplot2 39 | #' @export 40 | 41 | plot.design_aov <- function(x,...){ 42 | 43 | return(x$meansplot) 44 | 45 | } -------------------------------------------------------------------------------- /R/methods.opt_alpha.R: -------------------------------------------------------------------------------- 1 | #' Methods for opt_alpha objects 2 | #' 3 | #' Methods defined for objects returned from the optimal_alpha and ANOVA_compromise functions. 4 | #' 5 | #' @param x object of class \code{opt_alpha} as returned from one of the optimal alpha functions in Superpower. 6 | #' @param ... further arguments passed through, see description of return value 7 | #' for details. 8 | #' \code{\link{ANOVA_compromise}}. 9 | #' @return 10 | #' \describe{ 11 | #' \item{\code{print}}{Prints short summary of the optimal alpha results} 12 | #' \item{\code{plot}}{Returns a plot} 13 | #' } 14 | #' 15 | #' @name opt_alpha-methods 16 | 17 | 18 | ### methods for opt_alpha 19 | 20 | #' @rdname opt_alpha-methods 21 | #' @method print opt_alpha 22 | #' @export 23 | 24 | print.opt_alpha <- function(x,...){ 25 | if (x$method == "ANOVA_compromise") { 26 | cat("Optimal Alpha & Beta for ANOVA tests") 27 | cat("\n") 28 | print(x$aov_comp, digits=4) 29 | cat("\n") 30 | if (!is.null(x$emmeans_comp)) { 31 | cat("\n") 32 | cat("Optimal Alpha & Beta for Estimated Marginal Means") 33 | cat("\n") 34 | print(x$emmeans_comp, digits = 4) 35 | cat("\n") 36 | } 37 | } else if(x$method == "optimal_alpha") { 38 | df_res = data.frame(Alpha = x$alpha, 39 | Beta = x$beta, 40 | 'Weighted Combined Error Rate' = x$objective) 41 | cat("\n") 42 | cat("Optimal Alpha") 43 | cat("\n") 44 | print(df_res) 45 | cat("\n") 46 | cat("From power function:") 47 | cat("\n") 48 | print(x$power_function) 49 | cat("\n") 50 | } 51 | 52 | } 53 | 54 | #' @rdname opt_alpha-methods 55 | #' @method plot opt_alpha 56 | #' @import ggplot2 57 | #' @export 58 | 59 | plot.opt_alpha <- function(x,...){ 60 | if (x$method == "ANOVA_compromise") { 61 | return(x$aov_plotlist) 62 | } else if (x$method == "optimal_alpha") { 63 | return(x$plot) 64 | } 65 | 66 | } 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /R/misc_functions.R: -------------------------------------------------------------------------------- 1 | ci_binom = function(centx,n,conf_level=.95){ 2 | p <- centx/100 3 | x <- p*n 4 | alpha <- 1 - conf_level 5 | alpha2 <- 0.5 * alpha 6 | z <- qnorm(1 - alpha2) 7 | z2 <- z * z 8 | # Wilson, E. B. (1927). Probable Inference, the Law of Succession, and Statistical Inference. Journal of the American Statistical Association, 22(158), 209–212. https://doi.org/10.1080/01621459.1927.10502953 9 | p1 <- p + 0.5 * z2/n 10 | p2 <- z * sqrt((p * (1 - p) + 0.25 * z2/n)/n) 11 | p3 <- 1 + z2/n 12 | lcl <- (p1 - p2)/p3 13 | ucl <- (p1 + p2)/p3 14 | res = c(lcl,ucl) 15 | return(res) 16 | } 17 | 18 | 19 | 20 | smean.sdl = function (x, mult = 1, na.rm = TRUE) { 21 | if (na.rm) 22 | x <- x[!is.na(x)] 23 | n <- length(x) 24 | if (n == 0) 25 | return(c(Mean = NA, Lower = NA, Upper = NA)) 26 | xbar <- sum(x)/n 27 | sd <- sqrt(sum((x - xbar)^2)/(n - 1)) 28 | c(Mean = xbar, Lower = xbar - mult * sd, Upper = xbar + 29 | mult * sd) 30 | } -------------------------------------------------------------------------------- /R/mu_from_ES.R: -------------------------------------------------------------------------------- 1 | #' Convenience function to calculate the means for between designs with one factor (One-Way ANOVA). Can be used to determine the means that should yield a specified effect sizes (expressed in Cohen's f). 2 | #' @param K Number of groups (2, 3, or 4) 3 | #' @param ES Effect size (eta-squared) 4 | #' @return Returns vector of means 5 | #' @examples 6 | #' ## Medium effect size (eta-squared), 2 groups 7 | #' ES <- 0.0588 8 | #' K <- 2 9 | #' mu_from_ES(K = K, ES = ES) 10 | #' @section References: 11 | #' Albers, C., & Lakens, D. (2018). When power analyses based on pilot data are biased: Inaccurate effect size estimators and follow-up bias. Journal of Experimental Social Psychology, 74, 187–195. https://doi.org/10.1016/j.jesp.2017.09.004 12 | #' @import ggplot2 13 | #' @export 14 | 15 | mu_from_ES <- function(K, ES){ # provides the vector of population means for a given population ES and nr of groups 16 | 17 | if (ES >= 1 | ES <= 0 ) { 18 | stop("the ES (partial eta squared) must be less than 1 and greater than zero") 19 | } 20 | 21 | if (K == 2 | K == 3 | K == 4 ){ 22 | 23 | } else{stop("Number of levels (k) must be 2, 3, or 4")} 24 | 25 | f2 <- ES/(1-ES) 26 | if(K == 2){ 27 | a <- sqrt(f2) 28 | muvec <- c(-a,a) 29 | } 30 | if(K == 3){ 31 | a <- sqrt(3*f2/2) 32 | muvec <- c(-a, 0, a) 33 | } 34 | if(K == 4){ 35 | a <- sqrt(f2) 36 | muvec <- c(-a, -a, a, a) 37 | } # note: function gives error when K not 2,3,4. But we don't need other K. 38 | return(muvec) 39 | } 40 | -------------------------------------------------------------------------------- /R/p_standardized.R: -------------------------------------------------------------------------------- 1 | #' Compute standardized alpha level based on unstandardized alpha level and the number of observations N. 2 | #' @param p The observed p-value. 3 | #' @param N The number of observations (e.g., the sample size) in the dataset 4 | #' @param standardize_N The number of observations (e.g., the sample size) you want to use to standardize the alpha level for. Defaults to 100 (base on Good, 1982). 5 | #' @examples 6 | #' ## Check it yields .05 for N = 100: 7 | #' p_standardized(p = 0.05, N = 100) 8 | #' ## Check it yields .05 for N = 200, p = 0.03535534: 9 | #' p_standardized(p = 0.03535534, N = 200) 10 | #' ## What is a standardized p-value for p = .05 and N = 200? 11 | #' p_standardized(p = 0.05, N = 200) 12 | #' ## You can change the standardization N, repeating the example above: 13 | #' p_standardized(p = 0.05, N = 100, standardize_N = 200) 14 | #' @section References: 15 | #' Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 16 | #' @export 17 | #' 18 | p_standardized <- function(p, N, standardize_N = 100){ 19 | p * sqrt(N/standardize_N) 20 | } 21 | -------------------------------------------------------------------------------- /R/power_oneway_between.R: -------------------------------------------------------------------------------- 1 | #' Analytic power calculation for one-way between designs. 2 | #' @param design_result Output from the ANOVA_design function 3 | #' @param alpha_level Alpha level used to determine statistical significance 4 | #' @return 5 | #' mu = means 6 | #' 7 | #' sigma = standard deviation 8 | #' 9 | #' n = sample size 10 | #' 11 | #' alpha_level = alpha level 12 | #' 13 | #' Cohen_f = Cohen f 14 | #' 15 | #' f_2 = Cohen's f^2 16 | #' 17 | #' lambda = lambda 18 | #' 19 | #' F_critical = Critical F-value 20 | #' 21 | #' power = power 22 | #' 23 | #' df1 = degrees of freedom for the effect 24 | #' 25 | #' df2 = degrees of freedom of the error 26 | #' 27 | #' eta_p_2 = partial eta-squared 28 | #' 29 | #' mean_mat = matrix of the means 30 | #' 31 | #' @examples 32 | #' ## Set up a within design with one factor with 2 levels, 33 | #' ## 40 participants (woh do all conditions), and standard deviation of 2 34 | #' ## with a mean pattern of 1, 0, 1, conditions labeled 'condition' 35 | #' ## with names for levels of "cheerful", "neutral", "sad" 36 | #' design_result <- ANOVA_design(design = "3b", n = 40, mu = c(1, 0, 1), 37 | #' sd = 2, labelnames = c("condition", "cheerful", "neutral", "sad")) 38 | #' power_result <- power_oneway_between(design_result, alpha_level = 0.05) 39 | #' @section References: 40 | #' too be added 41 | #' @importFrom stats pf qf 42 | #' @export 43 | #' 44 | power_oneway_between <- function(design_result, alpha_level=0.05){ 45 | 46 | #Error message if design other than 1-way between is input 47 | if (length(design_result$factors) != 1 || design_result$design_factors != 0 ) { 48 | stop("Only one-way between designs allowed for this function") 49 | } 50 | 51 | mean_mat <- t(matrix(design_result$mu, 52 | nrow = length(design_result$mu)/design_result$factors, 53 | ncol = design_result$factors)) #Create a mean matrix 54 | colnames(mean_mat) <- design_result$design_list 55 | rownames(mean_mat) <- design_result$factornames 56 | 57 | # Using the sweep function to remove rowmeans from the matrix 58 | mean_mat_res <- sweep(mean_mat,2, rowMeans(mean_mat)) 59 | mean_mat_res 60 | MS_A <- design_result$n * (sum(mean_mat_res^2)/(length(design_result$mu)-1)) 61 | SS_A <- design_result$n * sum(mean_mat_res^2) 62 | MS_error <- design_result$sd^2 63 | SS_error <- MS_error * (design_result$n*length(design_result$mu)) 64 | df1 <- length(design_result$mu)-1 65 | df2 <- (design_result$n*length(design_result$mu) - length(design_result$mu)) 66 | eta_p_2 <- SS_A/(SS_A+SS_error) 67 | f_2 <- eta_p_2/(1-eta_p_2) 68 | lambda <- f_2 * design_result$n * length(design_result$mu) 69 | # Cohen_f <- sqrt(sum(mean_mat_res^2)/length(design_result$mu))/sd #based on G*power manual page 28 70 | # We just take the sqrt(f_2) because formula above assumes maximum difference of means. 71 | Cohen_f <- sqrt(f_2) 72 | F_critical <- qf(alpha_level, df1, df2, lower.tail=FALSE) # Critical F-Value 73 | power <- (pf(F_critical, df1, df2, lambda, lower.tail = FALSE))*100 # power 74 | 75 | invisible(list(mu = design_result$mu, 76 | sigma = design_result$sd, 77 | n = design_result$n, 78 | alpha_level = alpha_level, 79 | Cohen_f = Cohen_f, 80 | f_2 = f_2, 81 | lambda = lambda, 82 | F_critical = F_critical, 83 | power = power, 84 | df1 = df1, 85 | df2 = df2, 86 | eta_p_2 = eta_p_2, 87 | mean_mat = mean_mat)) 88 | } 89 | -------------------------------------------------------------------------------- /R/power_standardized_alpha.R: -------------------------------------------------------------------------------- 1 | #' Optimizing function to achieve desired power based on a standardized alpha level. 2 | #' 3 | #' Because the standardized alpha depends on the sample size (N), and the power depends on the sample size, deciding upon the sample size to achieve a desired power requires an iterative procedure. Increasing the sample size reduces the standardized alpha, which requires an increase in the sample size for the power analysis, which reduces the standardized alpha. This function takes a power analysis function that outputs the power as a function of the desired power, the alpha level, as a function of N(x). 4 | #' @param power_function Function that outputs the power, calculated with an analytic function. 5 | #' @param alpha The unstandardized alpha level (e.g., 0.05), independent of the sample size. 6 | #' @param power The desired power, i.e., the outcome of the power calculation you would like to achieve. 7 | #' @param standardize_N The sample size you want to use to standardize the alpha level for. Defaults to 100 (based on Good, 1982). 8 | #' @param verbose Set to FALSE to not print results (default = TRUE) 9 | #' @return List of 3 objects: a_stan = standardized alpha, N = sample size, and objective = for the weighted combined error rate. 10 | #' 11 | #' @examples 12 | #' \donttest{ 13 | #' res <- power_standardized_alpha(power_function = "pwr::pwr.t.test(d = 0.3, 14 | #' n = x, sig.level = a_stan, type = 'two.sample', 15 | #' alternative = 'two.sided')$power", power = 0.9, alpha = 0.05) 16 | #' res$N 17 | #' } 18 | #' @section References: 19 | #' Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 20 | #' @importFrom stats optimize 21 | #' @export 22 | #' 23 | 24 | power_standardized_alpha <- function(power_function, 25 | alpha = 0.05, 26 | power = 0.8, 27 | standardize_N = 100, 28 | verbose = Superpower_options("verbose")) { 29 | 30 | #Define the function to be minimized 31 | f = function(x, power_function, power, standardize_N) { 32 | #Calculate standardized alpha based on current N (x), the unstandardized alpha, and standardizer N 33 | a_stan <- alpha/sqrt(x/standardize_N) 34 | #Calculate power 35 | y <- eval(parse(text=paste(power_function))) 36 | #if(verbose == TRUE){ 37 | # print(x, y, max(y - power, power - y)) 38 | #} 39 | max(y - power, power - y) 40 | } 41 | 42 | #Run optimize to find the minimum 43 | res <- optimize(f, 44 | c(3, 1000), 45 | tol = 0.001, 46 | power_function = power_function, 47 | power = power, 48 | standardize_N = standardize_N) 49 | a_stan <- alpha/sqrt(ceiling(res$minimum)/standardize_N) 50 | if(verbose == TRUE){ 51 | mes = paste0("The standardized alpha is", a_stan) 52 | print(mes) 53 | } 54 | #Store results 55 | invisible(list(N = ceiling(res$minimum), 56 | a_stan = a_stan, 57 | objective = res$objective 58 | )) 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | ## set default options for Superpower_options: 2 | .onLoad <- function(libname, pkgname) { 3 | op <- options() 4 | op.Superpower <- list( 5 | Superpower.verbose = TRUE, 6 | Superpower.emm = FALSE, 7 | Superpower.emm_model = "multivariate", 8 | Superpower.contrast_type = "pairwise", 9 | Superpower.plot = TRUE, 10 | Superpower.alpha_level = .05, 11 | Superpower.correction = "none", 12 | Superpower.liberal_lambda = FALSE 13 | ) 14 | toset <- !(names(op.Superpower) %in% names(op)) 15 | if (any(toset)) options(op.Superpower[toset]) 16 | 17 | 18 | 19 | invisible() 20 | } -------------------------------------------------------------------------------- /README_files/figure-gfm/mean-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/mean-plot-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/sim-interaction-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/sim-interaction-2-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/sim-interaction-2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/sim-interaction-2-2.png -------------------------------------------------------------------------------- /README_files/figure-gfm/sim-interaction-2-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/sim-interaction-2-3.png -------------------------------------------------------------------------------- /README_files/figure-gfm/sim-interaction-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/sim-interaction-3-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/sim-interaction-3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/sim-interaction-3-2.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-11-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-11-2.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-11-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-11-3.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-11-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-11-4.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-26-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-26-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-27-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-27-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-28-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-28-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-29-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-29-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-30-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-30-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-31-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-31-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-32-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-32-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-33-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-33-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-34-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-34-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-35-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-35-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-36-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-36-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-37-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-37-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-38-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-38-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-39-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-39-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-40-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-40-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /README_files/figure-gfm/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-gfm/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /README_files/figure-latex/mean-plot-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/mean-plot-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/sim-interaction-2-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/sim-interaction-2-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/sim-interaction-2-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/sim-interaction-2-2.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/sim-interaction-2-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/sim-interaction-2-3.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/sim-interaction-3-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/sim-interaction-3-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/sim-interaction-3-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/sim-interaction-3-2.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-1-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-1-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-11-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-11-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-11-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-11-2.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-11-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-11-3.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-11-4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-11-4.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-12-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-12-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-19-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-19-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-20-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-20-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-22-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-22-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-26-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-26-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-28-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-28-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-29-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-29-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-32-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-32-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-4-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-4-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-6-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-6-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-7-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-7-1.pdf -------------------------------------------------------------------------------- /README_files/figure-latex/unnamed-chunk-8-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/README_files/figure-latex/unnamed-chunk-8-1.pdf -------------------------------------------------------------------------------- /Shiny/Justify/report.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Optimal Alpha Results" 3 | subtitle: "Shiny App developed by Daniël Lakens and Aaron Caldwell" 4 | output: pdf_document 5 | 6 | date: '`r format(Sys.time(), "%B %d, %Y")`' 7 | params: 8 | tablePC: NA, 9 | tableMain: NA, 10 | means_plot: NA, 11 | n: NA, 12 | model: NA, 13 | design: NA, 14 | cor_mat: NA, 15 | sigmatrix: NA 16 | alpha_level: NA 17 | tableEMM: NA 18 | input_emm: NA 19 | --- 20 | 21 | 22 | ```{r setup, warning=FALSE, message=FALSE, echo=FALSE} 23 | options(knitr.table.format = 'markdown') 24 | ``` 25 | 26 | 27 | Below are the results from a compromise power analysis wherein an optimal alpha and beta are provided as output. If you encounter any problems please visit our GitHub page (https://github.com/arcaldwell49/Superpower) to the raise the issue. 28 | 29 | **Study Design** 30 | 31 | `r paste(params$design)` 32 | 33 | **Model Formula** 34 | 35 | `r paste(params$model)` 36 | 37 | The sample size was **`r params$n`** *per cell*. 38 | 39 | **Correlation Matrix** 40 | ```{r echo = FALSE} 41 | knitr::kable(params$cor_mat) 42 | ``` 43 | 44 | **Variance-Covariance Matrix** 45 | ```{r echo = FALSE} 46 | knitr::kable(params$sigmatrix) 47 | ``` 48 | 49 | ```{r, results='asis', echo=FALSE} 50 | cat("\\newpage") 51 | ``` 52 | 53 | Plot of the design with mean and standard deviation. 54 | 55 | ```{r echo = FALSE} 56 | params$means_plot 57 | ``` 58 | 59 | 60 | ```{r, results='asis', echo=FALSE} 61 | cat("\\newpage") 62 | ``` 63 | 64 | With a sample size (per group) of `r params$n` the following optimal alpha and beta error rates are included below. 65 | 66 | **ANOVA-level Effects** 67 | 68 | ```{r echo = FALSE} 69 | knitr::kable(params$tableMain) 70 | 71 | ``` 72 | 73 | **Estimated Marginal Means Effects** 74 | 75 | If estimated marginal means were selected, the results are included below. 76 | 77 | ```{r echo = FALSE} 78 | if (params$input_emm == "yes") { 79 | knitr::kable(params$tableEMM) 80 | } 81 | ``` 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Shiny/Justify/rsconnect/shinyapps.io/arcaldwell49/justify.dcf: -------------------------------------------------------------------------------- 1 | name: justify 2 | title: 3 | username: 4 | account: arcaldwell49 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 7251722 8 | bundleId: 6383021 9 | url: https://arcaldwell49.shinyapps.io/justify/ 10 | when: 1665254747.75985 11 | lastSyncTime: 1665254747.75987 12 | -------------------------------------------------------------------------------- /Shiny/anova-exact/report.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Power Analysis Results: Exact Simulation" 3 | subtitle: "Shiny App developed by Daniël Lakens and Aaron Caldwell" 4 | output: pdf_document 5 | 6 | date: '`r format(Sys.time(), "%B %d, %Y")`' 7 | params: 8 | tablePC: NA, 9 | tableMain: NA, 10 | means_plot: NA, 11 | n: NA, 12 | model: NA, 13 | design: NA, 14 | cor_mat: NA, 15 | sigmatrix: NA 16 | alpha_level: NA 17 | tableEMM: NA 18 | input_emm: NA 19 | session: NA 20 | --- 21 | 22 | 23 | ```{r setup, warning=FALSE, message=FALSE, echo=FALSE} 24 | options(knitr.table.format = 'markdown') 25 | library(dplyr) 26 | library(scales) 27 | 28 | valr = function(x){ 29 | val = ifelse(x == 0, 30 | 0.0000, 31 | ifelse(x > 0.0001, 32 | round(x,4),"<0.0001")) 33 | return(val) 34 | } 35 | ``` 36 | 37 | 38 | Below are the results from a power analysis using an exact simulation of a factorial design wherein the data are sampled from an empirical distribution. If you encounter any problems please visit our GitHub page (https://github.com/arcaldwell49/Superpower) to the raise the issue. 39 | 40 | # Study Design 41 | 42 | `r paste(params$design)` 43 | 44 | **Model Formula** 45 | 46 | `r paste(params$model)` 47 | 48 | The sample size was **`r params$n`** *per cell* with a total number of observations of **`r params$n*length(diag(as.matrix(params$sigmatrix)))`**. 49 | 50 | **Correlation Matrix** 51 | ```{r echo = FALSE} 52 | knitr::kable(params$cor_mat |> 53 | as.data.frame() |> 54 | mutate_if(is.numeric, valr)) 55 | ``` 56 | 57 | **Variance-Covariance Matrix** 58 | ```{r echo = FALSE} 59 | knitr::kable(params$sigmatrix |> 60 | as.data.frame() |> 61 | mutate_if(is.numeric, valr)) 62 | ``` 63 | 64 | ```{r, results='asis', echo=FALSE} 65 | cat("\\newpage") 66 | ``` 67 | 68 | # Visual 69 | 70 | Plot of the design with mean and standard deviation. 71 | 72 | ```{r echo = FALSE} 73 | params$means_plot 74 | ``` 75 | 76 | 77 | ```{r, results='asis', echo=FALSE} 78 | cat("\\newpage") 79 | ``` 80 | 81 | # ANOVA 82 | Power for this specific design, with an alpha of `r params$alpha_level`, is included below. 83 | 84 | **ANOVA Power (%) and Effect Sizes (Partial Eta Squared)** 85 | 86 | ```{r echo = FALSE} 87 | knitr::kable(params$tableMain|> 88 | as.data.frame() |> 89 | mutate_if(is.numeric, valr)) 90 | 91 | ``` 92 | 93 | **Estimated Marginal Means Comparisons Power (%) and Effect Sizes (Cohen's *f*)** 94 | 95 | If estimated marginal means were selected, the results are included below. 96 | 97 | ```{r echo = FALSE} 98 | if(params$input_emm == "yes"){ 99 | knitr::kable(params$tableEMM|> 100 | as.data.frame() |> 101 | mutate_if(is.numeric, valr)) 102 | } 103 | ``` 104 | 105 | ```{r, results='asis', echo=FALSE} 106 | cat("\\newpage") 107 | ``` 108 | 109 | # Multiple Comparisons 110 | **t*-test, Power (%) and Effect Sizes (Cohen's d~z~)** 111 | 112 | Below are the power analysis results if all pairwise comparisons are completed via *t*-tests 113 | 114 | ```{r echo = FALSE} 115 | knitr::kable(params$tablePC|> 116 | as.data.frame() |> 117 | mutate_if(is.numeric, valr)) 118 | ``` 119 | 120 | ```{r, results='asis', echo=FALSE} 121 | cat("\\newpage") 122 | ``` 123 | 124 | # Details 125 | 126 | Printed session information from R. 127 | 128 | ```{r, echo = FALSE} 129 | #params$session$R.version$version.string 130 | pander::pander(params$session) 131 | ``` 132 | 133 | -------------------------------------------------------------------------------- /Shiny/anova-exact/rsconnect/shinyapps.io/arcaldwell49/anova-exact.dcf: -------------------------------------------------------------------------------- 1 | name: anova-exact 2 | title: 3 | username: 4 | account: arcaldwell49 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 7251624 8 | bundleId: 6834234 9 | url: https://arcaldwell49.shinyapps.io/anova-exact/ 10 | when: 1676073764.84199 11 | lastSyncTime: 1676073764.842 12 | asMultiple: FALSE 13 | asStatic: FALSE 14 | -------------------------------------------------------------------------------- /Shiny/anova-power/rsconnect/shinyapps.io/arcaldwell49/anova-power.dcf: -------------------------------------------------------------------------------- 1 | name: anova-power 2 | title: 3 | username: 4 | account: arcaldwell49 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 7251682 8 | bundleId: 6820646 9 | url: https://arcaldwell49.shinyapps.io/anova-power/ 10 | when: 1675798933.39544 11 | lastSyncTime: 1675798933.39546 12 | asMultiple: FALSE 13 | asStatic: FALSE 14 | -------------------------------------------------------------------------------- /Shiny/morey_plots/rsconnect/shinyapps.io/arcaldwell49/morey_plots.dcf: -------------------------------------------------------------------------------- 1 | name: morey_plots 2 | title: 3 | username: 4 | account: arcaldwell49 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 7251747 8 | bundleId: 6383034 9 | url: https://arcaldwell49.shinyapps.io/morey_plots/ 10 | when: 1665255394.83286 11 | lastSyncTime: 1665255394.83287 12 | -------------------------------------------------------------------------------- /Sticker/AVENGEANCE.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/AVENGEANCE.ttf -------------------------------------------------------------------------------- /Sticker/Marvel-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/Marvel-Regular.ttf -------------------------------------------------------------------------------- /Sticker/Super.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/Super.png -------------------------------------------------------------------------------- /Sticker/Superpower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/Superpower.png -------------------------------------------------------------------------------- /Sticker/Superpower2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/Superpower2.PNG -------------------------------------------------------------------------------- /Sticker/Superpower2_v2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/Superpower2_v2.PNG -------------------------------------------------------------------------------- /Sticker/authors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/authors.png -------------------------------------------------------------------------------- /Sticker/justiceleague.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/justiceleague.ttf -------------------------------------------------------------------------------- /Sticker/letters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/letters.png -------------------------------------------------------------------------------- /Sticker/script.R: -------------------------------------------------------------------------------- 1 | 2 | library(Superpower) 3 | library(reshape2) 4 | library(tidyverse) 5 | library(hexSticker) 6 | library(showtext) 7 | 8 | ## Loading Google fonts (http://www.google.com/fonts) 9 | #font_add_google("Supermercado One", "supermercado") 10 | #font_add_google("Modak", "modak") 11 | #font_add_google("Play", "play") 12 | 13 | font_add("marvel", "Sticker/Marvel-Regular.ttf") 14 | font_add("avenger", "Sticker/AVENGEANCE.ttf") 15 | font_add("justice", "Sticker/justiceleague.ttf") 16 | 17 | ## Automatically use showtext to render text for future devices 18 | showtext_auto() 19 | 20 | sticker_design <- ANOVA_design("2b", n = 30, 21 | sd = 1, 22 | mu = c(0,.55), 23 | plot = FALSE) 24 | 25 | power_sticker <- ANOVA_power(sticker_design, 26 | verbose = FALSE, 27 | nsims = 20000) 28 | 29 | 30 | plotData <- power_sticker$sim_data %>% filter(anova_a < .5) 31 | #power_sticker2 = ggplot(power_sticker$sim_data, aes(x = anova_a)) + 32 | # scale_x_continuous("", limits=c(0,.5)) + #expand = c(0, 0), 33 | # scale_y_continuous("",limits=c(0,10.5)) + 34 | # annotate('text', x = 0.25, y = 9.5, 35 | # label = "1-beta ", 36 | # parse = TRUE,size=20, 37 | # color = "white") + 38 | # geom_density() + 39 | # geom_segment(aes(x=.05,xend=.05,y=0,yend=8.9), color = "chocolate1") + 40 | #labs(title = "1 - \U03B2") + 41 | # theme_void() + 42 | # theme_transparent() + 43 | # theme( 44 | # strip.background = element_blank(), 45 | # strip.text.y = element_blank(), 46 | # axis.text.x = element_blank(), 47 | # axis.text.y = element_blank(), 48 | # axis.ticks = element_blank(), 49 | # text=element_text(family = "play") 50 | # ) 51 | 52 | power_sticker2 = ggplot(plotData, aes(x = anova_a)) + 53 | scale_x_continuous("", limits = c(0,.5)) + #expand = c(0, 0), 54 | scale_y_continuous("") + 55 | geom_density() + 56 | geom_segment(aes(x = .05,xend = .05,y = 0,yend = 15.5), color = "#FFFF00") + 57 | #labs(title = "Marvel") + 58 | theme_void() + 59 | theme_transparent() + 60 | theme( 61 | strip.background = element_blank(), 62 | strip.text.y = element_blank(), 63 | axis.text.x = element_blank(), 64 | axis.text.y = element_blank(), 65 | axis.ticks = element_blank(), 66 | text = element_text() 67 | ) 68 | 69 | 70 | #plot.title = element_text(size = 65, 71 | # hjust = .5, 72 | # color = "white", 73 | # margin=margin(0,0,0,0)), 74 | 75 | 76 | #Plot p-value dist 77 | 78 | 79 | #power_sticker2 <- power_sticker$plot1 80 | #power_sticker2 <- power_sticker2 + 81 | # scale_x_continuous("",expand = c(0, 0)) + 82 | # scale_y_continuous("",expand = c(0, 0)) + 83 | # annotate('text', x = 0.5, y = 75, 84 | # label = "1~-~beta ", 85 | # parse = TRUE,size=20) + 86 | # theme(strip.background = element_blank(), 87 | # strip.text.y = element_blank(), 88 | # axis.text.x = element_blank(), 89 | # axis.text.y = element_blank(), 90 | # axis.ticks = element_blank()) + 91 | #theme_void() + 92 | # theme_transparent() 93 | 94 | 95 | 96 | 97 | sticker( 98 | power_sticker2, 99 | package = "Superpower", 100 | p_family = "justice", 101 | p_size = 24, 102 | s_x = .99, 103 | s_y = .80, 104 | s_width = .9, 105 | s_height = .9, 106 | h_color = "#FF0000", 107 | h_fill = "#3366CC"#, #blue4 #chocolate1, #CC0000 108 | #filename = "baseplot.png" 109 | ) 110 | 111 | sticker( 112 | power_sticker2, 113 | package = "", 114 | p_family = "justice", 115 | p_size = 24, 116 | s_x = .99, 117 | s_y = .75, 118 | s_width = .9, 119 | s_height = .9, 120 | h_color = "#FF0000", 121 | h_fill = "blue2"#, #blue4 #chocolate1, #CC0000 122 | #filename = "baseplot.png" 123 | ) 124 | -------------------------------------------------------------------------------- /Sticker/superman style 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/superman style 2.png -------------------------------------------------------------------------------- /Sticker/superman style 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/superman style 3.png -------------------------------------------------------------------------------- /Sticker/superman style.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Sticker/superman style.png -------------------------------------------------------------------------------- /Superpower.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 870dd11e-df87-4a0c-9624-0f3d259ed0dc 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: Sweave 14 | LaTeX: pdfLaTeX 15 | 16 | BuildType: Package 17 | PackageUseDevtools: Yes 18 | PackageInstallArgs: --no-multiarch --with-keep.source 19 | PackageRoxygenize: rd,collate,namespace 20 | -------------------------------------------------------------------------------- /Validation/ANCOVA_twoway_sims_files/figure-gfm/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Validation/ANCOVA_twoway_sims_files/figure-gfm/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /Validation/ANCOVA_twoway_sims_files/figure-gfm/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/Validation/ANCOVA_twoway_sims_files/figure-gfm/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | home: 2 | title: The Superpower R package 3 | description: An R pacakge for easy power analyses (mainly through simulation) 4 | 5 | 6 | template: 7 | opengraph: 8 | image: 9 | src: Sticker/Superpower2.PNG 10 | alt: "Superpower logo" 11 | twitter: 12 | creator: "@exphysstudent" 13 | card: summary_large_image 14 | 15 | reference: 16 | - title: "Settings" 17 | contents: 18 | - Superpower_options 19 | 20 | - title: "ANOVA" 21 | 22 | - subtitle: "Design" 23 | contents: 24 | - ANOVA_design 25 | - print.design_aov 26 | - plot.design_aov 27 | 28 | - subtitle: "Power" 29 | contents: 30 | - ANOVA_power 31 | - ANOVA_exact 32 | - ANOVA_exact2 33 | - emmeans_power 34 | - plot_power 35 | - print.sim_result 36 | - plot.sim_result 37 | - confint.sim_result 38 | 39 | - title: "ANCOVA" 40 | contents: 41 | - ANCOVA_analytic 42 | - ANCOVA_contrast 43 | - ancova_power-methods 44 | 45 | - title: "Justify your Alpha" 46 | desc: > 47 | Compromise functions for finding an optimal alpha level 48 | contents: 49 | - alpha_standardized 50 | - ANOVA_compromise 51 | - optimal_alpha 52 | - p_standardized 53 | - power_standardized_alpha 54 | - opt_alpha-methods 55 | 56 | - title: "Sensitivity Functions" 57 | contents: 58 | - morey_plot.ftest 59 | - morey_plot.ttest 60 | 61 | - title: "Other Power Functions" 62 | contents: 63 | - power.ftest 64 | - power_oneway_ancova 65 | - power_oneway_between 66 | - power_oneway_within 67 | - power_twoway_between 68 | - power_threeway_between 69 | - mu_from_ES -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * ubuntu, Windows, and MacOS on GitHub Actions 3 | 4 | ## R CMD check results 5 | 6 | 0 errors | 0 warnings | 0 note 7 | 8 | * This is a new release. 9 | 10 | ## Other Comments 11 | 12 | * Author names in the DESCRIPTION are correctly spelled (i.e., Lakens and Caldwell) 13 | * Minor change to the citation to stay on CRAN 14 | * Will address the "additional notes" ASAP 15 | 16 | -------------------------------------------------------------------------------- /docs/Superpower2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/Superpower2.PNG -------------------------------------------------------------------------------- /docs/articles/ANCOVAs_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/ANCOVAs_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/ANCOVAs_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/ANCOVAs_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/ANCOVAs_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/comp_plots-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/comp_plots-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/comp_plots-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/comp_plots-2.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/comp_plots-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/comp_plots-3.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/compromise_power_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/compromise_power_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/emmeans_power_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/emmeans_power_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/emmeans_power_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/emmeans_power_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/emmeans_power_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/morey1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/morey1-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/morey2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/morey2-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/intro_to_superpower_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/intro_to_superpower_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/mean-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/mean-plot-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/more_anova_designs_files/figure-html/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/more_anova_designs_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/screenshots/PS2000.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/PS2000.gif -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_1.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_10.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_11.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_12.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_14.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_5.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_6.png -------------------------------------------------------------------------------- /docs/articles/screenshots/gpower_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/screenshots/gpower_9.png -------------------------------------------------------------------------------- /docs/articles/sim_data/vig_1_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/articles/sim_data/vig_1_plot.png -------------------------------------------------------------------------------- /docs/authors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/authors.png -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $("div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.2' 2 | pkgdown: 2.0.7 3 | pkgdown_sha: ~ 4 | articles: 5 | ANCOVAs: ANCOVAs.html 6 | compromise_power: compromise_power.html 7 | emmeans_power: emmeans_power.html 8 | intro_to_superpower: intro_to_superpower.html 9 | more_anova_designs: more_anova_designs.html 10 | last_built: 2024-10-22T12:39Z 11 | 12 | -------------------------------------------------------------------------------- /docs/reference/ANOVA_design-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/ANOVA_design-1.png -------------------------------------------------------------------------------- /docs/reference/ANOVA_exact-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/ANOVA_exact-1.png -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/figures/Superpower2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/figures/Superpower2.PNG -------------------------------------------------------------------------------- /docs/reference/figures/authors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/figures/authors.png -------------------------------------------------------------------------------- /docs/reference/optimal_alpha-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/optimal_alpha-1.png -------------------------------------------------------------------------------- /docs/reference/power_oneway_between-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/power_oneway_between-1.png -------------------------------------------------------------------------------- /docs/reference/power_oneway_within-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/power_oneway_within-1.png -------------------------------------------------------------------------------- /docs/reference/power_threeway_between-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/power_threeway_between-1.png -------------------------------------------------------------------------------- /docs/reference/power_twoway_between-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/docs/reference/power_twoway_between-1.png -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /404.html 5 | 6 | 7 | /articles/ANCOVAs.html 8 | 9 | 10 | /articles/compromise_power.html 11 | 12 | 13 | /articles/emmeans_power.html 14 | 15 | 16 | /articles/index.html 17 | 18 | 19 | /articles/intro_to_superpower.html 20 | 21 | 22 | /articles/more_anova_designs.html 23 | 24 | 25 | /authors.html 26 | 27 | 28 | /index.html 29 | 30 | 31 | /LICENSE-text.html 32 | 33 | 34 | /LICENSE.html 35 | 36 | 37 | /news/index.html 38 | 39 | 40 | /reference/alpha_standardized.html 41 | 42 | 43 | /reference/ANCOVA_analytic.html 44 | 45 | 46 | /reference/ANCOVA_contrast.html 47 | 48 | 49 | /reference/ancova_power-methods.html 50 | 51 | 52 | /reference/ANOVA_compromise.html 53 | 54 | 55 | /reference/ANOVA_design.html 56 | 57 | 58 | /reference/ANOVA_exact.html 59 | 60 | 61 | /reference/ANOVA_power.html 62 | 63 | 64 | /reference/design_aov-methods.html 65 | 66 | 67 | /reference/emmeans_power.html 68 | 69 | 70 | /reference/index.html 71 | 72 | 73 | /reference/morey_plot.html 74 | 75 | 76 | /reference/mu_from_ES.html 77 | 78 | 79 | /reference/optimal_alpha.html 80 | 81 | 82 | /reference/opt_alpha-methods.html 83 | 84 | 85 | /reference/plot_power.html 86 | 87 | 88 | /reference/power.ftest.html 89 | 90 | 91 | /reference/power_oneway_ancova.html 92 | 93 | 94 | /reference/power_oneway_between.html 95 | 96 | 97 | /reference/power_oneway_within.html 98 | 99 | 100 | /reference/power_standardized_alpha.html 101 | 102 | 103 | /reference/power_threeway_between.html 104 | 105 | 106 | /reference/power_twoway_between.html 107 | 108 | 109 | /reference/p_standardized.html 110 | 111 | 112 | /reference/sim_result-methods.html 113 | 114 | 115 | /reference/Superpower_options.html 116 | 117 | 118 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # Superpower 2 | 3 | plot of chunk hex 4 | plot of chunk authors 5 | 6 | 7 | [![R build status](https://github.com/arcaldwell49/Superpower/workflows/R-CMD-check/badge.svg)](https://github.com/arcaldwell49/Superpower/actions) 8 | [![CRAN status](https://www.r-pkg.org/badges/version/Superpower)](https://CRAN.R-project.org/package=Superpower) 9 | [![codecov](https://codecov.io/gh/arcaldwell49/Superpower/branch/master/graph/badge.svg)](https://app.codecov.io/gh/arcaldwell49/Superpower) 10 | [![](https://img.shields.io/badge/doi-10.31234/osf.io/baxsf-yellow.svg)](https://doi.org/10.31234/osf.io/baxsf) 11 | 12 | 13 | 14 | The goal of `Superpower` is to easily simulate factorial designs and empirically calculate power using a simulation approach. 15 | This package and its functions are intended to be utilized for prospective (a priori) power analysis. In addition to this site we have written a short [book](https://aaroncaldwell.us/SuperpowerBook/) documenting a wide range of applications of this package and how to perform power analysis outside this R package using custom code. 16 | 17 | ## Installation 18 | 19 | You can install the most recent version of `Superpower` from [GitHub](https://github.com/arcaldwell49/Superpower) with: 20 | 21 | ``` r 22 | devtools::install_github("arcaldwell49/Superpower") 23 | ``` 24 | 25 | Or you can install the stable version of Superpower from [CRAN](https://CRAN.R-project.org) with: 26 | 27 | 28 | ``` r 29 | install.packages("Superpower") 30 | ``` 31 | 32 | ## Citation 33 | 34 | If you use `Superpower`, please consider citing the following: 35 | 36 | Lakens, D., & Caldwell, A. R. (2021). Simulation-Based Power Analysis for Factorial Analysis of 37 | Variance Designs. *Advances in Methods and Practices in Psychological Science*, 4(1), 38 | 251524592095150. https://doi.org/10.1177/2515245920951503 39 | 40 | ``` 41 | A BibTeX entry for LaTeX users is 42 | 43 | @Article{, 44 | doi = {10.1177/2515245920951503}, 45 | url = {https://doi.org/10.1177/2515245920951503}, 46 | year = {2021}, 47 | volume = {4}, 48 | number = {1}, 49 | pages = {251524592095150}, 50 | author = {Daniel Lakens and Aaron Caldwell}, 51 | title = {Simulation-Based Power Analysis for Factorial Analysis of Variance Designs}, 52 | journal = {Advances in Methods and Practices in Psychological Science}, 53 | } 54 | ``` 55 | 56 | ## Other Simulation & Power Analysis Packages 57 | 58 | We started this project to create a simple way to do ANOVA power calculations that the average experimental scientist can use. However, there are many cases that an ANOVA may not be appropriate. Therefore, we suggest using other packages such as `simr` which allows for linear and generalized mixed models. Custom code can also be written and for such specialized simulations we highly recommend the `simstudy` R package. For sequential analyses and adaptive designs the `rpact` package will also be very helpful. 59 | 60 | * [simstudy](https://www.rdatagen.net/page/simstudy/): Simulation of Study Data 61 | * [faux](https://debruine.github.io/faux/): Simulate data with a specified structure. 62 | * [simr](https://github.com/pitakakariki/simr): Power Analysis of Generalised Linear Mixed Models by Simulation 63 | * [rpact](https://www.rpact.org/): Confirmatory Adaptive Clinical Trial Design, Simulation, and Analysis 64 | * [pwr](https://github.com/heliosdrm/pwr): Basic functions for power analysis 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite Superpower in publications, please use:") 2 | 3 | bibentry(bibtype = "Article", 4 | doi = "10.1177/2515245920951503", 5 | url = "https://doi.org/10.1177/2515245920951503", 6 | year = "2021", 7 | volume = "4", 8 | number = "1", 9 | pages = "251524592095150", 10 | author = c(person(given = "Daniel", family = "Lakens", 11 | email = "D.Lakens@tue.nl"), 12 | person(given = "Aaron", family = "Caldwell", 13 | email = "arcaldwell49@gmail.com")), 14 | title = "Simulation-Based Power Analysis for Factorial Analysis of Variance Designs", 15 | journal = "Advances in Methods and Practices in Psychological Science", 16 | textVersion = "Lakens, D., & Caldwell, A. R. (2021). Simulation-Based Power Analysis for Factorial Analysis of Variance Designs. Advances in Methods and Practices in Psychological Science, 4(1), 251524592095150. https://doi.org/10.1177/2515245920951503" 17 | ) -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | ANCOVA 2 | ANCOVAs 3 | Aberson 4 | Albers 5 | AxB 6 | Bonferroni 7 | CMD 8 | DATASIM 9 | Diener 10 | Dunnett 11 | Englewood 12 | Erlbaum 13 | Feldt 14 | GG 15 | GPower 16 | Geisser 17 | Generalised 18 | Gpower 19 | Heisey 20 | Hillsdale 21 | Hoenig 22 | Huynh 23 | JustifieR 24 | Keppel 25 | Morey 26 | Mudge 27 | Neyman 28 | Noncentrality 29 | Pavot 30 | Pillai's 31 | Potvin 32 | Psychometrika 33 | README 34 | Routledge 35 | Scheffe 36 | Schutz 37 | Shieh 38 | Sidak 39 | Splode 40 | UI 41 | Ulrich 42 | WCER 43 | afex 44 | al 45 | ancova 46 | anova 47 | aov 48 | b’ 49 | cdot 50 | codecov 51 | cohen 52 | cohen's 53 | confint 54 | consec 55 | cov 56 | ctrl 57 | ctrlk 58 | del 59 | design’ 60 | df 61 | dfs 62 | disordinal 63 | doi 64 | dplyr 65 | dunnettx 66 | emm 67 | emmGrid 68 | emmeans 69 | et 70 | expected’ 71 | frac 72 | ftest 73 | grey 74 | homoscedascity 75 | htest 76 | https 77 | jesp 78 | kableExtra 79 | labelnames 80 | labelnameslist 81 | list’ 82 | magrittr 83 | manova 84 | matricies 85 | meansplot 86 | morey 87 | mu’ 88 | nd 89 | noncentrality 90 | nsims 91 | num 92 | oneway 93 | overline 94 | param 95 | pc 96 | pes 97 | priori 98 | pwr 99 | revpairwise 100 | rpact 101 | scheffe 102 | sd 103 | sidak 104 | simr 105 | simstudy 106 | sphericity 107 | stan 108 | trt 109 | tukey 110 | ’ 111 | -------------------------------------------------------------------------------- /jamovi/0000.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | title: Simulation-Based Power Analysis for ANOVA Designs 3 | name: ANOVApower 4 | version: 0.0.3 5 | jms: '1.0' 6 | authors: 7 | - Aaron Caldwell 8 | - Daniel Lakens 9 | maintainer: Aaron Caldwell 10 | type: R 11 | description: >- 12 | Functions to perform simulations of ANOVA designs of up to three factors. 13 | Calculates the observed power and average observed effect size for all main 14 | effects and interactions in the ANOVA, and all simple comparisons between 15 | conditions. Includes functions for analytic power calculations and additional 16 | helper functions that compute effect sizes for ANOVA designs, observed error 17 | rates in the simulations, and functions to plot power curves. 18 | analyses: 19 | - title: ANOVA power 20 | name: jmvpower 21 | ns: ANOVApower 22 | menuGroup: ANOVApower 23 | menuTitle: ANOVA power 24 | 25 | ... 26 | -------------------------------------------------------------------------------- /jamovi/jmvpower.a.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: jmvpower 3 | title: ANOVA power 4 | menuGroup: ANOVApower 5 | version: '1.0.0' 6 | jas: '1.2' 7 | 8 | options: 9 | - name: design 10 | title: Design 11 | type: String 12 | default: 2b*2w 13 | description: 14 | R: a string describing the design 15 | 16 | - name: labelnames 17 | title: Factor labels 18 | type: String 19 | default: "AGE,old,young,SPEED,fast,slow" 20 | description: 21 | R: a comma separated string describing the factor and level labels 22 | 23 | - name: n 24 | title: Sample size in each condition 25 | type: Integer 26 | default: 80 27 | min: 3 28 | description: 29 | R: an integer specifying the sample size in each condition 30 | 31 | - name: sd 32 | title: Standard deviation 33 | type: Number 34 | default: 1.03 35 | min: .0001 36 | description: 37 | R: a number specifying the group standard deviations 38 | 39 | - name: r 40 | title: Correlation 41 | type: Number 42 | default: 0.87 43 | description: 44 | R: a number specifying the correlation between dependent variables 45 | 46 | - name: mu 47 | title: Group means 48 | type: String 49 | default: "1.03, 1.21, 0.98, 1.01" 50 | description: 51 | R: a comma separated string specifying the group means 52 | 53 | - name: plot 54 | title: Plot means 55 | type: Bool 56 | default: true 57 | description: 58 | R: > 59 | `TRUE` (default) or `FALSE` specifying whether to provide a means plot 60 | 61 | - name: simulate 62 | title: Run simulation 63 | type: Bool 64 | default: false 65 | hidden: true 66 | description: 67 | R: > 68 | `TRUE` or `FALSE` (default); perform the simulation 69 | 70 | - name: alpha_level 71 | title: Alpha level 72 | type: Number 73 | min: 0 74 | max: 1 75 | default: 0.05 76 | description: 77 | R: a number specifying the alpha level 78 | 79 | - name: nsims 80 | title: Number of simulations 81 | type: Integer 82 | min: 100 83 | max: 10000 84 | default: 100 85 | description: 86 | R: an integer specifying the number of simulations to perform 87 | 88 | - name: p_adjust 89 | title: Adjustment method for multiple comparisons 90 | type: List 91 | options: 92 | - name: none 93 | title: None 94 | - name: holm 95 | title: Holm-Bonferroni 96 | - name: bonferroni 97 | title: Bonferroni 98 | - name: fdr 99 | title: False discovery rate 100 | default: holm 101 | description: 102 | R: the p-adjustment method to use 103 | ... 104 | -------------------------------------------------------------------------------- /jamovi/jmvpower.r.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: jmvpower 3 | title: ANOVA power 4 | jrs: '1.1' 5 | 6 | items: 7 | - name: design 8 | title: Design 9 | type: Group 10 | items: 11 | - name: summary 12 | title: Design 13 | type: Table 14 | rows: 4 15 | columns: 16 | - name: name 17 | title: '' 18 | type: text 19 | - name: value 20 | title: '' 21 | type: text 22 | clearWith: 23 | - design 24 | - labelnames 25 | - n 26 | - sd 27 | - r 28 | - mu 29 | 30 | - name: matrix 31 | title: Correlation matrix 32 | type: Table 33 | columns: [] 34 | clearWith: 35 | - design 36 | - labelnames 37 | - n 38 | - sd 39 | - r 40 | - mu 41 | 42 | - name: plot 43 | title: Means plot 44 | type: Image 45 | visible: (plot) 46 | renderFun: .plot 47 | clearWith: 48 | - design 49 | - labelnames 50 | - n 51 | - sd 52 | - r 53 | - mu 54 | 55 | - name: sims 56 | title: Simulation 57 | type: Group 58 | items: 59 | - name: results 60 | title: Results 61 | type: Table 62 | visible: (simulate) 63 | columns: 64 | - name: name 65 | title: '' 66 | type: text 67 | - name: power 68 | title: Power 69 | - name: es 70 | title: Effect-size 71 | clearWith: 72 | - design 73 | - labelnames 74 | - n 75 | - sd 76 | - r 77 | - mu 78 | - nsims 79 | - alpha_level 80 | - p_adjust 81 | 82 | - name: multi 83 | title: Multiple comparisons 84 | type: Table 85 | visible: (simulate) 86 | columns: 87 | - name: name 88 | title: '' 89 | type: text 90 | - name: power 91 | title: Power 92 | - name: es 93 | title: Effect-size 94 | clearWith: 95 | - design 96 | - labelnames 97 | - n 98 | - sd 99 | - r 100 | - mu 101 | - nsims 102 | - alpha_level 103 | - p_adjust 104 | 105 | # - name: text 106 | # title: debug 107 | # type: Preformatted 108 | 109 | 110 | ... 111 | -------------------------------------------------------------------------------- /jamovi/jmvpower.u.yaml: -------------------------------------------------------------------------------- 1 | title: ANOVA power 2 | name: jmvpower 3 | jus: '2.0' 4 | stage: 0 5 | compilerMode: tame 6 | events: 7 | loaded: './main::loaded' 8 | children: 9 | - type: Label 10 | label: Design 11 | margin: large 12 | children: 13 | - type: TextBox 14 | name: design 15 | format: string 16 | events: 17 | change: './main::onChange_option' 18 | - type: TextBox 19 | name: labelnames 20 | format: string 21 | width: largest 22 | events: 23 | change: './main::onChange_option' 24 | - type: TextBox 25 | name: 'n' 26 | format: number 27 | events: 28 | change: './main::onChange_option' 29 | - type: TextBox 30 | name: sd 31 | format: number 32 | events: 33 | change: './main::onChange_option' 34 | - type: TextBox 35 | name: r 36 | format: number 37 | events: 38 | change: './main::onChange_option' 39 | - type: TextBox 40 | name: mu 41 | format: string 42 | width: largest 43 | events: 44 | change: './main::onChange_option' 45 | - type: CheckBox 46 | name: plot 47 | - type: Label 48 | label: Simulation 49 | margin: large 50 | children: 51 | - type: TextBox 52 | name: alpha_level 53 | format: number 54 | events: 55 | change: './main::onChange_option' 56 | - type: TextBox 57 | name: nsims 58 | format: number 59 | events: 60 | change: './main::onChange_option' 61 | - type: ComboBox 62 | name: p_adjust 63 | events: 64 | change: './main::onChange_option' 65 | -------------------------------------------------------------------------------- /jamovi/js/css.js: -------------------------------------------------------------------------------- 1 | 2 | const css = ` 3 | 4 | #sim { 5 | display: inline-block ; 6 | margin-left: 12px ; 7 | padding: 12px ; 8 | background: #3498db; 9 | background-image: linear-gradient(to bottom, #3498db, #2980b9); 10 | box-shadow: 0px 1px 3px #666666; 11 | color: white 12 | } 13 | 14 | #sim:hover { 15 | background: #3cb0fd; 16 | background-image: linear-gradient(to bottom, #3cb0fd, #3498db); 17 | } 18 | 19 | #sim:active { 20 | background: #3498db; 21 | background-image: linear-gradient(to bottom, #3498db, #2980b9); 22 | } 23 | 24 | `; 25 | let node = document.createElement('style'); 26 | node.innerHTML = css; 27 | document.body.appendChild(node); 28 | 29 | module.exports = undefined; 30 | -------------------------------------------------------------------------------- /jamovi/js/main.js: -------------------------------------------------------------------------------- 1 | 2 | require('./css'); 3 | 4 | const events = { 5 | loaded(ui) { 6 | 7 | let $contents = ui.view.$el; 8 | 9 | let $button = $(`
    Run simulation
    `); 10 | $button.on('click', () => { 11 | ui.simulate.setValue(true); 12 | }); 13 | $button.appendTo($contents); 14 | }, 15 | 16 | onChange_option(ui, event) { 17 | ui.simulate.setValue(false); 18 | }, 19 | }; 20 | 21 | module.exports = events; 22 | -------------------------------------------------------------------------------- /man/ANCOVA_analytic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ANCOVA_analytic.R 3 | \name{ANCOVA_analytic} 4 | \alias{ANCOVA_analytic} 5 | \title{Power Calculations for Factorial ANCOVAs} 6 | \usage{ 7 | ANCOVA_analytic( 8 | design, 9 | mu, 10 | n = NULL, 11 | sd, 12 | r2 = NULL, 13 | n_cov, 14 | alpha_level = Superpower_options("alpha_level"), 15 | beta_level = NULL, 16 | cmats = list(), 17 | label_list = NULL, 18 | design_result = NULL, 19 | round_up = TRUE 20 | ) 21 | } 22 | \arguments{ 23 | \item{design}{Output from the ANOVA_design function} 24 | 25 | \item{mu}{Vector specifying mean for each condition} 26 | 27 | \item{n}{Sample size in each condition} 28 | 29 | \item{sd}{Standard deviation for all conditions (or a vector specifying the sd for each condition)} 30 | 31 | \item{r2}{Coefficient of Determination of the model with only the covariates} 32 | 33 | \item{n_cov}{Number of covariates} 34 | 35 | \item{alpha_level}{Alpha level used to determine statistical significance} 36 | 37 | \item{beta_level}{Type II error probability (power/100-1)} 38 | 39 | \item{cmats}{List of matrices for specific contrasts of interest} 40 | 41 | \item{label_list}{An optional list to specify the factor names and condition (recommended, if not used factors and levels are indicated by letters and numbers).} 42 | 43 | \item{design_result}{Output from the ANOVA_design function} 44 | 45 | \item{round_up}{Logical indicator (default = TRUE) for whether to round up sample size calculations to nearest whole number} 46 | } 47 | \value{ 48 | One, or two, data frames containing the power analysis results from the power analysis for the omnibus ANCOVA (main_results) or contrast tests (contrast_results). 49 | In addition, every F-test (aov_list and con_list) is included in a list of power.htest results. 50 | Lastly, a (design_param) list containing the design parameters is also included in the results. 51 | } 52 | \description{ 53 | Complete power analyses for ANCOVA omnibus tests and contrasts. This function does not support within subjects factors. 54 | } 55 | \section{References}{ 56 | 57 | Shieh, G. (2020). Power analysis and sample size planning in ANCOVA designs. Psychometrika, 85(1), 101-120. 58 | } 59 | 60 | \examples{ 61 | # Simple 2x3 ANCOVA 62 | 63 | ANCOVA_analytic( 64 | design = "2b*3b", 65 | mu = c(400, 450, 500, 66 | 400, 500, 600), 67 | n_cov = 3, 68 | sd = 100, 69 | r2 = .25, 70 | alpha_level = .05, 71 | beta_level = .2, 72 | round_up = TRUE 73 | ) 74 | } 75 | -------------------------------------------------------------------------------- /man/ANCOVA_contrast.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ANCOVA_contrast.R 3 | \name{ANCOVA_contrast} 4 | \alias{ANCOVA_contrast} 5 | \title{Power Calculations for ANCOVA Contrasts} 6 | \usage{ 7 | ANCOVA_contrast( 8 | cmat, 9 | mu, 10 | n = NULL, 11 | sd, 12 | r2 = NULL, 13 | n_cov, 14 | alpha_level = Superpower_options("alpha_level"), 15 | beta_level = NULL, 16 | round_up = TRUE 17 | ) 18 | } 19 | \arguments{ 20 | \item{cmat}{Matrix of the specific contrasts of interest} 21 | 22 | \item{mu}{Vector specifying mean for each condition} 23 | 24 | \item{n}{Sample size in each condition} 25 | 26 | \item{sd}{Standard deviation for all conditions (or a vector specifying the sd for each condition)} 27 | 28 | \item{r2}{Coefficient of Determination of the model with only the covariates} 29 | 30 | \item{n_cov}{Number of covariates} 31 | 32 | \item{alpha_level}{Alpha level used to determine statistical significance} 33 | 34 | \item{beta_level}{Type II error probability (power/100-1)} 35 | 36 | \item{round_up}{Logical indicator (default = TRUE) for whether to round up sample size calculations to nearest whole number} 37 | } 38 | \value{ 39 | Object of class "power.htest", a list of the arguments (including the computed one) augmented with method and note elements. 40 | } 41 | \description{ 42 | Complete power analyses for specific ANCOVA contrasts. This function does not support within subjects factors. 43 | } 44 | \section{References}{ 45 | 46 | Shieh, G. (2020). Power analysis and sample size planning in ANCOVA designs. Psychometrika, 85(1), 101-120. 47 | } 48 | 49 | \examples{ 50 | ANCOVA_contrast(cmat = c(-1,1), 51 | n = 15, 52 | mu = c(0,1), 53 | sd = 1, 54 | r2 = .2, 55 | n_cov = 1) 56 | } 57 | -------------------------------------------------------------------------------- /man/ANOVA_compromise.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ANOVA_compromise.R 3 | \name{ANOVA_compromise} 4 | \alias{ANOVA_compromise} 5 | \title{Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates for ANOVAs.} 6 | \usage{ 7 | ANOVA_compromise( 8 | design_result, 9 | correction = Superpower_options("correction"), 10 | emm = Superpower_options("emm"), 11 | emm_model = Superpower_options("emm_model"), 12 | contrast_type = Superpower_options("contrast_type"), 13 | emm_comp, 14 | costT1T2 = 1, 15 | priorH1H0 = 1, 16 | error = c("minimal", "balance"), 17 | liberal_lambda = Superpower_options("liberal_lambda") 18 | ) 19 | } 20 | \arguments{ 21 | \item{design_result}{Output from the ANOVA_design function} 22 | 23 | \item{correction}{Set a correction of violations of sphericity. This can be set to "none", "GG" Greenhouse-Geisser, and "HF" Huynh-Feldt} 24 | 25 | \item{emm}{Set to FALSE to not perform analysis of estimated marginal means} 26 | 27 | \item{emm_model}{Set model type ("multivariate", or "univariate") for estimated marginal means} 28 | 29 | \item{contrast_type}{Select the type of comparison for the estimated marginal means. Default is pairwise. See ?emmeans::`contrast-methods` for more details on acceptable methods.} 30 | 31 | \item{emm_comp}{Set the comparisons for estimated marginal means comparisons. This is a factor name (a), combination of factor names (a+b), or for simple effects a | sign is needed (a|b)} 32 | 33 | \item{costT1T2}{Relative cost of Type 1 errors vs. Type 2 errors.} 34 | 35 | \item{priorH1H0}{How much more likely a-priori is H1 than H0? Default is 1: equally likely.} 36 | 37 | \item{error}{Either "minimal" to minimize error rates, or "balance" to balance error rates.} 38 | 39 | \item{liberal_lambda}{Logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE.} 40 | } 41 | \value{ 42 | Returns dataframe with simulation data (power and effect sizes!), optimal alpha level, obtained beta error rate (1-power/100), and objective (see below for details). If NA is obtained in a alpha/beta/objective columns this indicates there is no effect for this particular comparison. Also returns alpha-beta compromise plots for all comparisons. Note: Cohen's f = sqrt(pes/1-pes) and the noncentrality parameter is = f^2*df(error) 43 | 44 | \describe{ 45 | \item{\code{"aov_comp"}}{A dataframe of ANOVA-level results.} 46 | \item{\code{"aov_plotlist"}}{List of plots for ANOVA-level effects} 47 | \item{\code{"manova_comp"}}{A dataframe of MANOVA-level results.} 48 | \item{\code{"manova_plotlist"}}{List of plots for MANOVA-level effects.} 49 | \item{\code{"emmeans_comp"}}{A dataframe of ANOVA-level results.} 50 | \item{\code{"emm_plotlist"}}{List of plots for estimated marginal means contrasts.} 51 | 52 | } 53 | alpha = alpha or Type 1 error that minimizes or balances combined error rates 54 | beta = beta or Type 2 error that minimizes or balances combined error rates 55 | objective = value that is the result of the minimization, either 0 (for balance) or the combined weighted error rates 56 | } 57 | \description{ 58 | Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates for ANOVAs. 59 | } 60 | \section{References}{ 61 | 62 | too be added 63 | } 64 | 65 | \examples{ 66 | \dontrun{ 67 | design_result <- ANOVA_design(design = "3b*2w", 68 | n = 6, 69 | mu = c(1, 2, 2, 3, 3, 4), 70 | sd = 3, 71 | plot = FALSE) 72 | example = ANOVA_compromise(design_result,emm = TRUE,emm_comp = "a") 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /man/ANOVA_design.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ANOVA_design.R 3 | \name{ANOVA_design} 4 | \alias{ANOVA_design} 5 | \title{Design function used to specify the parameters to be used in simulations} 6 | \usage{ 7 | ANOVA_design( 8 | design, 9 | n, 10 | mu, 11 | sd, 12 | r = 0, 13 | label_list = NULL, 14 | labelnames = NULL, 15 | plot = Superpower_options("plot") 16 | ) 17 | } 18 | \arguments{ 19 | \item{design}{String specifying the ANOVA design.} 20 | 21 | \item{n}{Sample size in each condition} 22 | 23 | \item{mu}{Vector specifying mean for each condition} 24 | 25 | \item{sd}{standard deviation for all conditions (or a vector specifying the sd for each condition)} 26 | 27 | \item{r}{Correlation between dependent variables (single value or matrix)} 28 | 29 | \item{label_list}{An optional list to specify the factor names and condition (recommended, if not used factors and levels are indicated by letters and numbers).} 30 | 31 | \item{labelnames}{Optional vector to specifying factor and condition names. This parameter is deprecated and will be overridden by input from label_list.} 32 | 33 | \item{plot}{Should means plot be printed (defaults to TRUE)} 34 | } 35 | \value{ 36 | Returns single list with simulated data, design, design list, factor names, formulas for ANOVA, means, sd, correlation, sample size per condition, correlation matrix, covariance matrix, design string, labelnames, labelnameslist, factor names, meansplot 37 | 38 | \describe{ 39 | \item{\code{"dataframe"}}{A sample dataframe of what data could look like given the proposed parameters.} 40 | \item{\code{"design"}}{\code{aov} The design string, e.g. "2b*2w".} 41 | \item{\code{"design_list"}}{The list of variables in the design.} 42 | \item{\code{"frml1"}}{The first formula created for this design.} 43 | \item{\code{"frml2"}}{The second formula created for this design.} 44 | \item{\code{"mu"}}{Vector of means.} 45 | \item{\code{"sd"}}{Vector of standard deviations.} 46 | \item{\code{"r"}}{Common correlation coefficient.} 47 | \item{\code{"n"}}{Sample size per cell. Can be entered as a single value or list of sample sizes for each condition. If unequal n is entered then the design can only be passed onto ANOVA_power.} 48 | \item{\code{"cor_mat"}}{The correlation matrix.} 49 | \item{\code{"sigmatrix"}}{The variance-covariance matrix.} 50 | \item{\code{"design_factors"}}{Total number of within-subjects factors.} 51 | \item{\code{"labelnames"}}{List of the label names.} 52 | \item{\code{"labelnameslist"}}{Secondary list of labelnames} 53 | \item{\code{"factornames"}}{List of the factor titles.} 54 | \item{\code{"meansplot"}}{Plot of the experimental design.} 55 | 56 | } 57 | } 58 | \description{ 59 | Design function used to specify the parameters to be used in simulations 60 | } 61 | \section{Warnings}{ 62 | 63 | Varying the sd or r (e.g., entering multiple values) violates assumptions of homoscedascity and sphericity respectively 64 | } 65 | 66 | \examples{ 67 | ## Set up a within design with 2 factors, each with 2 levels, 68 | ## with correlation between observations of 0.8, 69 | ## 40 participants (who do all conditions), and standard deviation of 2 70 | ## with a mean pattern of 1, 0, 1, 0, conditions labeled 'condition' and 71 | ## 'voice', with names for levels of "cheerful", "sad", and "human", "robot" 72 | ANOVA_design(design = "2w*2w", n = 40, mu = c(1, 0, 1, 0), sd = 2, r = 0.8, 73 | label_list= list(condition = c("cheerful", "sad"), 74 | voice = c("human", "robot"))) 75 | } 76 | -------------------------------------------------------------------------------- /man/Superpower_options.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Superpower_options.R 3 | \name{Superpower_options} 4 | \alias{Superpower_options} 5 | \title{Set/get global Superpower options} 6 | \usage{ 7 | Superpower_options(...) 8 | } 9 | \arguments{ 10 | \item{...}{One of four: (1) nothing, then returns all options as a list; (2) 11 | a name of an option element, then returns its' value; (3) a name-value pair 12 | which sets the corresponding option to the new value (and returns nothing), 13 | (4) a list with option-value pairs which sets all the corresponding 14 | arguments. The example show all possible cases.} 15 | } 16 | \value{ 17 | depends on input, see above. 18 | } 19 | \description{ 20 | Global Superpower options are used, for example, by \code{\link{ANOVA_exact}} (et al.) 21 | and \code{\link{ANOVA_power}}. But can be changed in each functions directly using 22 | an argument (which has precedence over the global options). 23 | } 24 | \details{ 25 | The following arguments are currently set: 26 | \itemize{ 27 | \item \code{verbose} should verbose (printed results) be set to true? Default is \code{TRUE}. 28 | \item \code{emm} Option to perform analysis of estimated marginal means. Default is \code{FALSE}. 29 | \item \code{emm_model} Model type ("multivariate", or "univariate") for estimated marginal means. Default is \code{"multivariate"}. 30 | \item \code{contrast_type} The type of comparison for the estimated marginal means. Default is \code{"pairwise"}. See ?emmeans::'contrast-methods' for more details on acceptable methods. 31 | \item \code{plot} Option to automatically print plots. Default is \code{FALSE}. 32 | \item \code{alpha_level} Alpha level used to determine statistical significance. Default is .05. 33 | \item \code{correction} Option to set a correction for sphericity violations. Default is no correction. This can be set to "none", "GG" Greenhouse-Geisser, and "HF" Huynh-Feldt 34 | \item \code{liberal_lambda} Option to set a logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE. 35 | } 36 | } 37 | \note{ 38 | All options are saved in the global R \code{\link{options}} with prefix 39 | \code{Superpower.} 40 | } 41 | -------------------------------------------------------------------------------- /man/alpha_standardized.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/alpha_standardized.R 3 | \name{alpha_standardized} 4 | \alias{alpha_standardized} 5 | \title{Compute standardized alpha level based on unstandardized alpha level and the number of observations N.} 6 | \usage{ 7 | alpha_standardized(alpha, N, standardize_N = 100) 8 | } 9 | \arguments{ 10 | \item{alpha}{The unstandardized alpha level (e.g., 0.05), independent of the sample size.} 11 | 12 | \item{N}{The number of observations (e.g., the sample size) in the dataset} 13 | 14 | \item{standardize_N}{The number of observations (e.g., the sample size) you want to use to standardize the alpha level for. Defaults to 100 (base on Good, 1982).} 15 | } 16 | \description{ 17 | Compute standardized alpha level based on unstandardized alpha level and the number of observations N. 18 | } 19 | \section{References}{ 20 | 21 | Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 22 | } 23 | 24 | \examples{ 25 | ## Check it yields .05 for N = 100: 26 | alpha_standardized(alpha = 0.05, N = 100) 27 | ## Check it yields .05 for N = 200: 28 | alpha_standardized(alpha = 0.07071068, N = 200) 29 | ## Which alpha should we use with N = 200? 30 | alpha_standardized(alpha = 0.05, N = 200) 31 | ## You can change the standardization N, repeating the example above: 32 | alpha_standardized(alpha = 0.05, N = 100, standardize_N = 200) 33 | } 34 | -------------------------------------------------------------------------------- /man/ancova_power-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.ancova_power.R 3 | \name{ancova_power-methods} 4 | \alias{ancova_power-methods} 5 | \alias{print.ancova_power} 6 | \alias{plot.ancova_power} 7 | \title{Methods for ancova_power objects} 8 | \usage{ 9 | \method{print}{ancova_power}(x, ...) 10 | 11 | \method{plot}{ancova_power}(x, ...) 12 | } 13 | \arguments{ 14 | \item{x}{object of class \code{ancova_power} as returned from one of the simulation functions in Superpower.} 15 | 16 | \item{...}{further arguments passed through, see description of return value} 17 | } 18 | \value{ 19 | \describe{ 20 | \item{\code{print}}{Prints short summary of the simulation result} 21 | \item{\code{plot}}{Returns a meansplot of from the defined design} 22 | } 23 | } 24 | \description{ 25 | Methods defined for objects returned from the ANCOVA_analytic function. 26 | } 27 | -------------------------------------------------------------------------------- /man/design_aov-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.design_aov.R 3 | \name{design_aov-methods} 4 | \alias{design_aov-methods} 5 | \alias{print.design_aov} 6 | \alias{plot.design_aov} 7 | \title{Methods for design_aov objects} 8 | \usage{ 9 | \method{print}{design_aov}(x, ...) 10 | 11 | \method{plot}{design_aov}(x, ...) 12 | } 13 | \arguments{ 14 | \item{x}{object of class \code{design_aov} as returned from \code{ANOVA_design}} 15 | 16 | \item{...}{further arguments passed through, see description of return value 17 | for details. 18 | \code{\link{ANOVA_design}}.} 19 | } 20 | \value{ 21 | \describe{ 22 | \item{\code{print}}{Prints short summary of the study design created from \code{ANOVA_design} function} 23 | \item{\code{plot}}{Returns \code{meansplot} from created from the \code{ANOVA_design} function} 24 | } 25 | } 26 | \description{ 27 | Methods defined for objects returned from the ANOVA_design functions. 28 | } 29 | -------------------------------------------------------------------------------- /man/figures/Superpower2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/man/figures/Superpower2.PNG -------------------------------------------------------------------------------- /man/figures/authors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/man/figures/authors.png -------------------------------------------------------------------------------- /man/morey_plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/morey_plots.R 3 | \name{morey_plot.ttest} 4 | \alias{morey_plot.ttest} 5 | \alias{morey_plot.ftest} 6 | \title{Plot out power sensitivity plots for t or F tests} 7 | \usage{ 8 | morey_plot.ttest( 9 | es = seq(0, 1, 0.05), 10 | n = NULL, 11 | type = c("two.sample", "one.sample", "paired"), 12 | alternative = c("two.sided", "one.sided"), 13 | alpha_level = Superpower_options("alpha_level") 14 | ) 15 | 16 | morey_plot.ftest( 17 | es = seq(0, 1, 0.05), 18 | num_df = 1, 19 | den_df = NULL, 20 | alpha_level = Superpower_options("alpha_level"), 21 | liberal_lambda = Superpower_options("liberal_lambda") 22 | ) 23 | } 24 | \arguments{ 25 | \item{es}{Effect size magnitudes to include on the plot; either cohen's f or cohen's d depending on whether it is an F-test or t-test} 26 | 27 | \item{n}{Sample size (t-test only) per group (two sample), total number of pairs (paired samples), or total observations (one-sample); only applies to t-test} 28 | 29 | \item{type}{string specifying the type of t test. Can be abbreviated. (t-test only)} 30 | 31 | \item{alternative}{one- or two-sided test. Can be abbreviated. (t-test only)} 32 | 33 | \item{alpha_level}{vector of alpha levels; default is 0.05} 34 | 35 | \item{num_df}{Numerator degrees of freedom for an F-test.} 36 | 37 | \item{den_df}{Denominator degrees of freedom for an F-test.} 38 | 39 | \item{liberal_lambda}{Logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE.} 40 | } 41 | \value{ 42 | Returns plots of effect size (x-axis) 43 | } 44 | \description{ 45 | Plot out power sensitivity plots for t or F tests 46 | } 47 | \section{Functions}{ 48 | \itemize{ 49 | \item \code{morey_plot.ttest()}: Power-sensitivity plot for t-tests 50 | 51 | \item \code{morey_plot.ftest()}: Power-sensitivity plot for F-tests 52 | 53 | }} 54 | \section{References}{ 55 | 56 | Morey, R.D. (2020). Power and precision Why the push for replacing “power” with “precision” is misguided. Retrieved from: \url{https://richarddmorey.medium.com/power-and-precision-47f644ddea5e} 57 | } 58 | 59 | \examples{ 60 | \dontrun{ 61 | # t-test example ------ 62 | # Sensitivity for cohen's d from .1 to .5 63 | # sample sizes of 10 and 20 64 | # alpha levels .05 and .075 65 | # type will be paired and one sided 66 | # Set effect sizes with seq function (?seq) 67 | 68 | morey_plot.ttest(es = seq(.1,.5,.01), 69 | n = c(10,20), 70 | alpha_level = c(.05,.075), 71 | type = "paired", 72 | alternative = "one.sided") 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /man/mu_from_ES.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mu_from_ES.R 3 | \name{mu_from_ES} 4 | \alias{mu_from_ES} 5 | \title{Convenience function to calculate the means for between designs with one factor (One-Way ANOVA). Can be used to determine the means that should yield a specified effect sizes (expressed in Cohen's f).} 6 | \usage{ 7 | mu_from_ES(K, ES) 8 | } 9 | \arguments{ 10 | \item{K}{Number of groups (2, 3, or 4)} 11 | 12 | \item{ES}{Effect size (eta-squared)} 13 | } 14 | \value{ 15 | Returns vector of means 16 | } 17 | \description{ 18 | Convenience function to calculate the means for between designs with one factor (One-Way ANOVA). Can be used to determine the means that should yield a specified effect sizes (expressed in Cohen's f). 19 | } 20 | \section{References}{ 21 | 22 | Albers, C., & Lakens, D. (2018). When power analyses based on pilot data are biased: Inaccurate effect size estimators and follow-up bias. Journal of Experimental Social Psychology, 74, 187–195. https://doi.org/10.1016/j.jesp.2017.09.004 23 | } 24 | 25 | \examples{ 26 | ## Medium effect size (eta-squared), 2 groups 27 | ES <- 0.0588 28 | K <- 2 29 | mu_from_ES(K = K, ES = ES) 30 | } 31 | -------------------------------------------------------------------------------- /man/opt_alpha-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.opt_alpha.R 3 | \name{opt_alpha-methods} 4 | \alias{opt_alpha-methods} 5 | \alias{print.opt_alpha} 6 | \alias{plot.opt_alpha} 7 | \title{Methods for opt_alpha objects} 8 | \usage{ 9 | \method{print}{opt_alpha}(x, ...) 10 | 11 | \method{plot}{opt_alpha}(x, ...) 12 | } 13 | \arguments{ 14 | \item{x}{object of class \code{opt_alpha} as returned from one of the optimal alpha functions in Superpower.} 15 | 16 | \item{...}{further arguments passed through, see description of return value 17 | for details. 18 | \code{\link{ANOVA_compromise}}.} 19 | } 20 | \value{ 21 | \describe{ 22 | \item{\code{print}}{Prints short summary of the optimal alpha results} 23 | \item{\code{plot}}{Returns a plot} 24 | } 25 | } 26 | \description{ 27 | Methods defined for objects returned from the optimal_alpha and ANOVA_compromise functions. 28 | } 29 | -------------------------------------------------------------------------------- /man/optimal_alpha.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/minimize_balance_alpha.R 3 | \name{optimal_alpha} 4 | \alias{optimal_alpha} 5 | \title{Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates.} 6 | \usage{ 7 | optimal_alpha( 8 | power_function, 9 | costT1T2 = 1, 10 | priorH1H0 = 1, 11 | error = c("minimal", "balance"), 12 | plot = Superpower_options("plot") 13 | ) 14 | } 15 | \arguments{ 16 | \item{power_function}{Function that outputs the power, calculated with an analytic function.} 17 | 18 | \item{costT1T2}{Relative cost of Type 1 errors vs. Type 2 errors.} 19 | 20 | \item{priorH1H0}{How much more likely a-priori is H1 than H0?} 21 | 22 | \item{error}{Either "minimal" to minimize error rates, or "balance" to balance error rate} 23 | 24 | \item{plot}{When set to TRUE, automatically outputs a plot of alpha (x-axis) and beta (y-axis) error rates} 25 | } 26 | \value{ 27 | alpha = alpha or Type 1 error that minimizes or balances combined error rates 28 | beta = beta or Type 2 error that minimizes or balances combined error rates 29 | objective = value that is the result of the minimization, either 0 (for balance) or the combined weighted error rates 30 | plot = 31 | } 32 | \description{ 33 | Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates. 34 | } 35 | \section{References}{ 36 | 37 | too be added 38 | } 39 | 40 | \examples{ 41 | ## Optimize power for a independent t-test, smallest effect of interest 42 | ## d = 0.5, 100 participants per condition 43 | res <- optimal_alpha(power_function = "pwr::pwr.t.test(d = 0.5, n = 100, 44 | sig.level = x, type = 'two.sample', alternative = 'two.sided')$power") 45 | res$alpha 46 | res$beta 47 | } 48 | -------------------------------------------------------------------------------- /man/p_standardized.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/p_standardized.R 3 | \name{p_standardized} 4 | \alias{p_standardized} 5 | \title{Compute standardized alpha level based on unstandardized alpha level and the number of observations N.} 6 | \usage{ 7 | p_standardized(p, N, standardize_N = 100) 8 | } 9 | \arguments{ 10 | \item{p}{The observed p-value.} 11 | 12 | \item{N}{The number of observations (e.g., the sample size) in the dataset} 13 | 14 | \item{standardize_N}{The number of observations (e.g., the sample size) you want to use to standardize the alpha level for. Defaults to 100 (base on Good, 1982).} 15 | } 16 | \description{ 17 | Compute standardized alpha level based on unstandardized alpha level and the number of observations N. 18 | } 19 | \section{References}{ 20 | 21 | Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 22 | } 23 | 24 | \examples{ 25 | ## Check it yields .05 for N = 100: 26 | p_standardized(p = 0.05, N = 100) 27 | ## Check it yields .05 for N = 200, p = 0.03535534: 28 | p_standardized(p = 0.03535534, N = 200) 29 | ## What is a standardized p-value for p = .05 and N = 200? 30 | p_standardized(p = 0.05, N = 200) 31 | ## You can change the standardization N, repeating the example above: 32 | p_standardized(p = 0.05, N = 100, standardize_N = 200) 33 | } 34 | -------------------------------------------------------------------------------- /man/power.ftest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/power_ftest.R 3 | \name{power.ftest} 4 | \alias{power.ftest} 5 | \title{Power Calculations for an F-test} 6 | \usage{ 7 | power.ftest( 8 | num_df = NULL, 9 | den_df = NULL, 10 | cohen_f = NULL, 11 | alpha_level = Superpower_options("alpha_level"), 12 | beta_level = NULL, 13 | liberal_lambda = Superpower_options("liberal_lambda") 14 | ) 15 | } 16 | \arguments{ 17 | \item{num_df}{degrees of freedom for numerator} 18 | 19 | \item{den_df}{degrees of freedom for denominator} 20 | 21 | \item{cohen_f}{Cohen's f effect size. Note: this is the sqrt(f2) if you are used to using pwr.f2.test} 22 | 23 | \item{alpha_level}{Alpha level used to determine statistical significance.} 24 | 25 | \item{beta_level}{Type II error probability (power/100-1)} 26 | 27 | \item{liberal_lambda}{Logical indicator of whether to use the liberal (cohen_f^2\*(num_df+den_df)) or conservative (cohen_f^2\*den_df) calculation of the noncentrality (lambda) parameter estimate. Default is FALSE.} 28 | } 29 | \value{ 30 | num_df = degrees of freedom for numerator, 31 | den_df = degrees of freedom for denominator, 32 | cohen_f = Cohen's f effect size, 33 | alpha_level = Type 1 error probability, 34 | beta_level = Type 2 error probability, 35 | power = Power of test (1-beta_level\*100%), 36 | lambda = Noncentrality parameter estimate (default = cohen_f^2\*den_df, liberal = cohen_f^2\*(num_df+den_df)) 37 | } 38 | \description{ 39 | Compute power of test or determine parameters to obtain target power. Inspired by the pwr.f2.test function in the pwr package, but allows for varying noncentrality parameter estimates for a more liberal (default in pwr.f2.test) or conservative (default in this function) estimates (see Aberson, Chapter 5, pg 72). 40 | } 41 | \section{References}{ 42 | 43 | Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale,NJ: Lawrence Erlbaum. 44 | Aberson, C. (2019). Applied Power Analysis for the Behavioral Sciences (2nd ed.). New York,NY: Routledge. 45 | } 46 | 47 | \examples{ 48 | design_result <- ANOVA_design(design = "2b", 49 | n = 65, 50 | mu = c(0,.5), 51 | sd = 1, 52 | plot = FALSE) 53 | x1 = ANOVA_exact2(design_result, verbose = FALSE) 54 | ex = power.ftest(num_df = x1$anova_table$num_df, 55 | den_df = x1$anova_table$den_df, 56 | cohen_f = x1$main_result$cohen_f, 57 | alpha_level = 0.05, 58 | liberal_lambda = FALSE) 59 | } 60 | -------------------------------------------------------------------------------- /man/power_oneway_ancova.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/oneway_ancova.R 3 | \name{power_oneway_ancova} 4 | \alias{power_oneway_ancova} 5 | \title{Power Calculations for a one-way ANCOVA} 6 | \usage{ 7 | power_oneway_ancova( 8 | n = NULL, 9 | mu = NULL, 10 | n_cov = 1, 11 | r2 = NULL, 12 | sd = 1, 13 | alpha_level = Superpower_options("alpha_level"), 14 | beta_level = NULL, 15 | round_up = TRUE, 16 | type = "exact" 17 | ) 18 | } 19 | \arguments{ 20 | \item{n}{Sample size in each condition.} 21 | 22 | \item{mu}{Vector specifying mean for each condition.} 23 | 24 | \item{n_cov}{Number of covariates.} 25 | 26 | \item{r2}{Coefficient of determination (r^2) of the combined covariates.} 27 | 28 | \item{sd}{Standard deviation for all conditions (residual SD without covariate adjustment).} 29 | 30 | \item{alpha_level}{Alpha level used to determine statistical significance.} 31 | 32 | \item{beta_level}{Type II error probability (power/100-1)} 33 | 34 | \item{round_up}{Logical indicator for whether to round up the sample size(s) to a whole number. Default is TRUE.} 35 | 36 | \item{type}{Sets the method for estimating power. "exact" will use the Shieh (2020) approach while "approx" will use the Keppel (1991) approach.} 37 | } 38 | \value{ 39 | dfs = degrees of freedom, 40 | N = Total sample size, 41 | n = Sample size per group/condition, 42 | n_cov = Number of covariates, 43 | mu = Mean for each condition, 44 | sd = Standard deviation, 45 | r2 = Coefficient of determination of combined covariates. 46 | alpha_level = Type 1 error probability, 47 | beta_level = Type 2 error probability, 48 | power = Power of test (1-beta_level\*100%), 49 | type = Method (Shieh or Keppel) for estimating power 50 | } 51 | \description{ 52 | Compute power of ANCOVA omnibus test (power_oneway_ancova) or contrast (power_oneway_ancova) for one-way (single factor), between subjects designs. 53 | } 54 | \section{References}{ 55 | 56 | Keppel, G. (1991). Design and Analysis A Researcher's Handbook. 3rd Edition. Prentice Hall. Englewood Cliffs, New Jersey. See pages 323 - 324. 57 | Shieh, G. (2017). Power and sample size calculations for contrast analysis in ANCOVA. Multivariate behavioral research, 52(1), 1-11. 58 | Shieh, G. (2020). Power analysis and sample size planning in ANCOVA designs. Psychometrika, 85(1), 101-120. 59 | } 60 | 61 | \examples{ 62 | # Example from Table 1 Shieh 2020 63 | power_oneway_ancova(mu = c(400, 450, 500), n = c(21,21,21), 64 | r2 = .1^2, sd = 100) 65 | } 66 | -------------------------------------------------------------------------------- /man/power_oneway_between.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/power_oneway_between.R 3 | \name{power_oneway_between} 4 | \alias{power_oneway_between} 5 | \title{Analytic power calculation for one-way between designs.} 6 | \usage{ 7 | power_oneway_between(design_result, alpha_level = 0.05) 8 | } 9 | \arguments{ 10 | \item{design_result}{Output from the ANOVA_design function} 11 | 12 | \item{alpha_level}{Alpha level used to determine statistical significance} 13 | } 14 | \value{ 15 | mu = means 16 | 17 | sigma = standard deviation 18 | 19 | n = sample size 20 | 21 | alpha_level = alpha level 22 | 23 | Cohen_f = Cohen f 24 | 25 | f_2 = Cohen's f^2 26 | 27 | lambda = lambda 28 | 29 | F_critical = Critical F-value 30 | 31 | power = power 32 | 33 | df1 = degrees of freedom for the effect 34 | 35 | df2 = degrees of freedom of the error 36 | 37 | eta_p_2 = partial eta-squared 38 | 39 | mean_mat = matrix of the means 40 | } 41 | \description{ 42 | Analytic power calculation for one-way between designs. 43 | } 44 | \section{References}{ 45 | 46 | too be added 47 | } 48 | 49 | \examples{ 50 | ## Set up a within design with one factor with 2 levels, 51 | ## 40 participants (woh do all conditions), and standard deviation of 2 52 | ## with a mean pattern of 1, 0, 1, conditions labeled 'condition' 53 | ## with names for levels of "cheerful", "neutral", "sad" 54 | design_result <- ANOVA_design(design = "3b", n = 40, mu = c(1, 0, 1), 55 | sd = 2, labelnames = c("condition", "cheerful", "neutral", "sad")) 56 | power_result <- power_oneway_between(design_result, alpha_level = 0.05) 57 | } 58 | -------------------------------------------------------------------------------- /man/power_oneway_within.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/power_oneway_within.R 3 | \name{power_oneway_within} 4 | \alias{power_oneway_within} 5 | \title{Analytic power calculation for one-way within designs.} 6 | \usage{ 7 | power_oneway_within(design_result, alpha_level = 0.05) 8 | } 9 | \arguments{ 10 | \item{design_result}{Output from the ANOVA_design function} 11 | 12 | \item{alpha_level}{Alpha level used to determine statistical significance} 13 | } 14 | \value{ 15 | mu = means 16 | 17 | sigma = standard deviation 18 | 19 | n = sample size 20 | 21 | alpha_level = alpha level 22 | 23 | Cohen_f = Cohen's f 24 | 25 | f_2 = Cohen's f squared 26 | 27 | lambda = lambda 28 | 29 | F_critical = Critical F-value 30 | 31 | power = power 32 | 33 | df1 = degrees of freedom for the effect 34 | 35 | df2 = degrees of freedom of the error 36 | 37 | eta_p_2 = partial eta-squared 38 | 39 | mean_mat = matrix of the means 40 | } 41 | \description{ 42 | Analytic power calculation for one-way within designs. 43 | } 44 | \section{References}{ 45 | 46 | too be added 47 | } 48 | 49 | \examples{ 50 | ## Set up a within design with 3 factors, 51 | ## with correlation between observations of 0.8, 52 | ## 40 participants (who do all conditions), and standard deviation of 2 53 | ## with a mean pattern of 1, 0, 1, conditions labeled 'condition' and 54 | ## 'voice', with names for levels of "cheerful", "neutral", "sad". 55 | design_result <- ANOVA_design(design = "3w", n = 40, r = 0.8, 56 | mu = c(1, 0, 1), sd = 2, 57 | labelnames = c("condition", "cheerful", "neutral", "sad")) 58 | power_result <- power_oneway_within(design_result, alpha_level = 0.05) 59 | } 60 | -------------------------------------------------------------------------------- /man/power_standardized_alpha.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/power_standardized_alpha.R 3 | \name{power_standardized_alpha} 4 | \alias{power_standardized_alpha} 5 | \title{Optimizing function to achieve desired power based on a standardized alpha level.} 6 | \usage{ 7 | power_standardized_alpha( 8 | power_function, 9 | alpha = 0.05, 10 | power = 0.8, 11 | standardize_N = 100, 12 | verbose = Superpower_options("verbose") 13 | ) 14 | } 15 | \arguments{ 16 | \item{power_function}{Function that outputs the power, calculated with an analytic function.} 17 | 18 | \item{alpha}{The unstandardized alpha level (e.g., 0.05), independent of the sample size.} 19 | 20 | \item{power}{The desired power, i.e., the outcome of the power calculation you would like to achieve.} 21 | 22 | \item{standardize_N}{The sample size you want to use to standardize the alpha level for. Defaults to 100 (based on Good, 1982).} 23 | 24 | \item{verbose}{Set to FALSE to not print results (default = TRUE)} 25 | } 26 | \value{ 27 | List of 3 objects: a_stan = standardized alpha, N = sample size, and objective = for the weighted combined error rate. 28 | } 29 | \description{ 30 | Because the standardized alpha depends on the sample size (N), and the power depends on the sample size, deciding upon the sample size to achieve a desired power requires an iterative procedure. Increasing the sample size reduces the standardized alpha, which requires an increase in the sample size for the power analysis, which reduces the standardized alpha. This function takes a power analysis function that outputs the power as a function of the desired power, the alpha level, as a function of N(x). 31 | } 32 | \section{References}{ 33 | 34 | Good, I. J. (1982). C140. Standardized tail-area probabilities. Journal of Statistical Computation and Simulation, 16(1), 65–66. 35 | } 36 | 37 | \examples{ 38 | \donttest{ 39 | res <- power_standardized_alpha(power_function = "pwr::pwr.t.test(d = 0.3, 40 | n = x, sig.level = a_stan, type = 'two.sample', 41 | alternative = 'two.sided')$power", power = 0.9, alpha = 0.05) 42 | res$N 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /man/power_twoway_between.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/power_twoway_between.R 3 | \name{power_twoway_between} 4 | \alias{power_twoway_between} 5 | \title{Analytic power calculation for two-way between designs.} 6 | \usage{ 7 | power_twoway_between(design_result, alpha_level = 0.05) 8 | } 9 | \arguments{ 10 | \item{design_result}{Output from the ANOVA_design function} 11 | 12 | \item{alpha_level}{Alpha level used to determine statistical significance} 13 | } 14 | \value{ 15 | mu = means 16 | 17 | sigma = standard deviation 18 | 19 | n = sample size 20 | 21 | alpha_level = alpha level 22 | 23 | Cohen_f_A = Cohen's f for main effect A 24 | 25 | Cohen_f_B = Cohen's f for main effect B 26 | 27 | Cohen_f_AB = Cohen's f for the A*B interaction 28 | 29 | f_2_A = Cohen's f squared for main effect A 30 | 31 | f_2_B = Cohen's f squared for main effect B 32 | 33 | f_2_AB = Cohen's f squared for A*B interaction 34 | 35 | lambda_A = lambda for main effect A 36 | 37 | lambda_B = lambda for main effect B 38 | 39 | lambda_AB = lambda for A*B interaction 40 | 41 | critical_F_A = critical F-value for main effect A 42 | 43 | critical_F_B = critical F-value for main effect B 44 | 45 | critical_F_AB = critical F-value for A*B interaction 46 | 47 | power_A = power for main effect A 48 | 49 | power_B = power for main effect B 50 | 51 | power_AB = power for A*B interaction 52 | 53 | df_A = degrees of freedom for main effect A 54 | 55 | df_B = degrees of freedom for main effect B 56 | 57 | df_AB = degrees of freedom for A*B interaction 58 | 59 | df_error = degrees of freedom for error term 60 | 61 | eta_p_2_A = partial eta-squared for main effect A 62 | 63 | eta_p_2_B = partial eta-squared for main effect B 64 | 65 | eta_p_2_AB = partial eta-squared for A*B interaction 66 | 67 | mean_mat = matrix of the means 68 | } 69 | \description{ 70 | Analytic power calculation for two-way between designs. 71 | } 72 | \section{References}{ 73 | 74 | too be added 75 | } 76 | 77 | \examples{ 78 | design_result <- ANOVA_design(design = "2b*2b", n = 40, mu = c(1, 0, 1, 0), 79 | sd = 2, labelnames = c("condition", "cheerful", "sad", 80 | "voice", "human", "robot")) 81 | power_result <- power_twoway_between(design_result, alpha_level = 0.05) 82 | } 83 | -------------------------------------------------------------------------------- /man/sim_result-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods.sim_result.R 3 | \name{sim_result-methods} 4 | \alias{sim_result-methods} 5 | \alias{print.sim_result} 6 | \alias{plot.sim_result} 7 | \alias{confint.sim_result} 8 | \title{Methods for sim_result objects} 9 | \usage{ 10 | \method{print}{sim_result}(x, ...) 11 | 12 | \method{plot}{sim_result}(x, ...) 13 | 14 | \method{confint}{sim_result}(object, parm = "main_results", level = 0.95, ...) 15 | } 16 | \arguments{ 17 | \item{x}{object of class \code{sim_result} as returned from one of the simulation functions in Superpower.} 18 | 19 | \item{...}{further arguments passed through, see description of return value} 20 | 21 | \item{object}{Result returned from ANOVA_power (only applicable argument for confint)} 22 | 23 | \item{parm}{Argument for confint. Select what results from the simulation to return with confidence intervals. Options currently include: main_results (default), pc_results, manova_results, and emm_results.} 24 | 25 | \item{level}{Argument for confint. Confidence level for binomial proportion confidence intervals (Wilson, 1927). Default is .95.} 26 | } 27 | \value{ 28 | \describe{ 29 | \item{\code{print}}{Prints short summary of the simulation result} 30 | \item{\code{plot}}{Returns \code{meansplot} or a plot of the distribution of p-values depending on whether an exact or Monte Carlo simulation was performed} 31 | \item{\code{confint}}{Returns confidence intervals for the selected result from ANOVA_power} 32 | } 33 | } 34 | \description{ 35 | Methods defined for objects returned from the ANOVA_exact, ANOVA_exact2, and ANOVA_power functions. 36 | } 37 | \section{References}{ 38 | 39 | Wilson, E. (1927). Probable Inference, the Law of Succession, and Statistical Inference. Journal of the American Statistical Association, 22(158), 209-212. doi:10.2307/2276774 40 | } 41 | 42 | -------------------------------------------------------------------------------- /mess/build and check package script.R: -------------------------------------------------------------------------------- 1 | #devtools::build() 2 | 3 | #Run the code below to ensure the package can be installed and passes all tests. 4 | 5 | #Possibly remove objects from environment rm(list = ls(all = TRUE)) 6 | #Also detach all packages to ensure tests will run w/o issue on Travis CI 7 | devtools::install() 8 | library(ANOVApower) 9 | devtools::test() 10 | #devtools::check() 11 | covr::package_coverage() 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /mess/old_functions/plot_power_oneway_between.R: -------------------------------------------------------------------------------- 1 | #' Convenience function to plot power across a range of sample sizes. 2 | #' @param design_result Output from the ANOVA_design function 3 | #' @param max_n Maximum sample size in power curve. 4 | #' @return Returns plots with power curves for the effects, and a dataframe with the summary data. 5 | #' @examples 6 | #' design_result <- ANOVA_design(design = "3b", 7 | #' n = 20, 8 | #' mu = c(0,0,0.3), 9 | #' sd = 1, 10 | #' labelnames = c("condition", 11 | #' "cheerful", "neutral", "sad")) 12 | #' 13 | #' plot_power_oneway_between(design_result, max_n = 30) 14 | #' @section References: 15 | #' too be added 16 | #' @import ggplot2 17 | #' @export 18 | 19 | plot_power_oneway_between <- function(design_result, max_n){ 20 | 21 | 22 | 23 | design = design_result$design 24 | mu = design_result$mu 25 | sd <- design_result$sd 26 | r <- design_result$r 27 | labelnames = c(design_result$factornames[[1]], design_result$labelnames[[1]]) 28 | 29 | n_vec <- seq(from = 5, to = max_n) 30 | 31 | power_A <- numeric(length(n_vec)) 32 | 33 | for (i in 1:length(n_vec)){ 34 | design_result <- ANOVA_design(design = design, 35 | n = n_vec[i], 36 | mu = mu, 37 | sd = sd, 38 | r = r, 39 | labelnames = labelnames) 40 | 41 | power_res <- power_oneway_between(design_result) 42 | 43 | power_A[i] <- power_res$power*100 44 | } 45 | 46 | res_df <- data.frame(n_vec, power_A) 47 | 48 | p1 <- ggplot(data=res_df, aes(x = n_vec, y = power_A)) + 49 | geom_line( size=1.5) + 50 | scale_x_continuous(limits = c(0, max(n_vec))) + 51 | scale_y_continuous(limits = c(0, 100)) + 52 | theme_bw() + 53 | labs(x="Sample size", y = "Power Factor A") 54 | 55 | invisible(list(p1 = p1, 56 | power_df = data.frame(paste("f = ", 57 | round(power_res$Cohen_f,2)), 58 | n_vec, 59 | power_A))) 60 | } 61 | -------------------------------------------------------------------------------- /mess/old_functions/plot_power_oneway_within.R: -------------------------------------------------------------------------------- 1 | #' Convenience function to plot power across a range of sample sizes. 2 | #' @param design_result Output from the ANOVA_design function 3 | #' @param max_n Maximum sample size in power curve. 4 | #' @return Returns plots with power curves for the effects, and a dataframe with the summary data. 5 | #' @examples 6 | #' design_result <- ANOVA_design(design = "3w", 7 | #' n = 20, 8 | #' mu = c(0,0,0.3), 9 | #' sd = 1, 10 | #' r = 0.7, 11 | #' labelnames = c("condition", 12 | #' "cheerful", "neutral", "sad")) 13 | #' 14 | #' plot_power_oneway_within(design_result, max_n = 30) 15 | #' @section References: 16 | #' too be added 17 | #' @import ggplot2 18 | #' @export 19 | 20 | plot_power_oneway_within <- function(design_result, max_n){ 21 | 22 | 23 | 24 | design = design_result$design 25 | mu = design_result$mu 26 | sd <- design_result$sd 27 | r <- design_result$r 28 | labelnames = c(design_result$factornames[[1]], design_result$labelnames[[1]]) 29 | 30 | 31 | n_vec <- seq(from = 5, to = max_n) 32 | 33 | power_A <- numeric(length(n_vec)) 34 | 35 | for (i in 1:length(n_vec)){ 36 | design_result <- ANOVA_design(design = design, 37 | n = n_vec[i], 38 | mu = mu, 39 | sd = sd, 40 | r = r, 41 | labelnames = labelnames) 42 | 43 | power_res <- power_oneway_within(design_result) 44 | 45 | power_A[i] <- power_res$power*100 46 | } 47 | 48 | res_df <- data.frame(n_vec, power_res$power) 49 | 50 | p1 <- ggplot(data=res_df, aes(x = n_vec, y = power_A)) + 51 | geom_line( size=1.5) + 52 | scale_x_continuous(limits = c(0, max(n_vec))) + 53 | scale_y_continuous(limits = c(0, 100)) + 54 | theme_bw() + 55 | labs(x="Sample size", y = "Power Factor A") 56 | 57 | invisible(list(p1 = p1, 58 | power_df = data.frame(paste("f = ", 59 | round(power_res$Cohen_f,2)), 60 | n_vec, 61 | power_A))) 62 | } 63 | -------------------------------------------------------------------------------- /mess/old_functions/plot_power_twoway_between.R: -------------------------------------------------------------------------------- 1 | #' Convenience function to plot power across a range of sample sizes. 2 | #' @param design_result Output from the ANOVA_design function 3 | #' @param max_n Maximum sample size in power curve. 4 | #' @return Returns plots with power curves for the effects, and a dataframe with the summary data. 5 | #' @examples 6 | #' design_result <- ANOVA_design(design = "2b*2b", 7 | #' n = 20, 8 | #' mu = c(0,0,0,0.3), 9 | #' sd = 1, 10 | #' labelnames = c("condition", "cheerful", "sad", 11 | #' "voice", "human", "robot")) 12 | #' 13 | #' plot_power_twoway_between(design_result, max_n = 30) 14 | #' @section References: 15 | #' too be added 16 | #' @import ggplot2 17 | #' @export 18 | 19 | plot_power_twoway_between <- function(design_result, max_n){ 20 | 21 | design = design_result$design 22 | mu = design_result$mu 23 | sd <- design_result$sd 24 | r <- design_result$r 25 | labelnames = c("A", "a1", "a2", "B", "b1", "b2") 26 | 27 | n_vec <- seq(from = 5, to = max_n) 28 | 29 | power_A <- numeric(length(n_vec)) 30 | power_B <- numeric(length(n_vec)) 31 | power_AB <- numeric(length(n_vec)) 32 | 33 | for (i in 1:length(n_vec)){ 34 | design_result <- ANOVA_design(design = design, 35 | n = n_vec[i], 36 | mu = mu, 37 | sd = sd, 38 | r = r, 39 | labelnames = labelnames) 40 | 41 | power_res <- power_twoway_between(design_result) 42 | 43 | power_A[i] <- power_res$power_A*100 44 | power_B[i] <- power_res$power_B*100 45 | power_AB[i] <- power_res$power_AB*100 46 | } 47 | 48 | res_df <- data.frame(n_vec, power_A, power_B, power_AB) 49 | 50 | p1 <- ggplot(data=res_df, aes(x = n_vec, y = power_A)) + 51 | geom_line( size=1.5) + 52 | scale_x_continuous(limits = c(0, max(n_vec))) + 53 | scale_y_continuous(limits = c(0, 100)) + 54 | theme_bw() + 55 | labs(x="Sample size", y = "Power Factor A") 56 | 57 | p2 <- ggplot(data=res_df, aes(x = n_vec, y = power_AB)) + 58 | geom_line( size=1.5) + 59 | scale_x_continuous(limits = c(0, max(n_vec))) + 60 | scale_y_continuous(limits = c(0, 100)) + 61 | theme_bw() + 62 | labs(x="Sample size", y = "Power Factor B") 63 | 64 | p3 <- ggplot(data=res_df, aes(x = n_vec, y = power_AB)) + 65 | geom_line( size=1.5) + 66 | scale_x_continuous(limits = c(0, max(n_vec))) + 67 | scale_y_continuous(limits = c(0, 100)) + 68 | theme_bw() + 69 | labs(x="Sample size", y = "Power Factor AB") 70 | 71 | invisible(list(p1 = p1, 72 | p2 = p2, 73 | p3 = p3, 74 | power_df = data.frame(paste("f = ", 75 | round(power_res$Cohen_f_A,2), 76 | " ", 77 | round(power_res$Cohen_f_B,2), 78 | " ", 79 | round(power_res$Cohen_f_AB,2), 80 | "\n", 81 | "r = ", 82 | r, 83 | " ", 84 | r, 85 | " ", 86 | r), 87 | n_vec, 88 | power_A, 89 | power_B, 90 | power_AB))) 91 | } 92 | -------------------------------------------------------------------------------- /mess/old_functions/test-plot_power_2x2_within.R: -------------------------------------------------------------------------------- 1 | context("test-plot_power_2x2_within") 2 | 3 | 4 | 5 | # error messages 6 | test_that("error messages", { 7 | 8 | design_result1 <- ANOVA_design(design = "2w*2w", 9 | n = 100, 10 | mu = c(24,26,25,27), 11 | sd = 6.4, 12 | plot = FALSE) 13 | 14 | 15 | expect_error(plot_power_2x2_within(), "argument \"design_result\" is missing, with no default" ) 16 | expect_error(plot_power_2x2_within(design_result1), "argument \"max_n\" is missing, with no default" ) 17 | 18 | }) 19 | -------------------------------------------------------------------------------- /mess/old_functions/test-plot_power_oneway_between.R: -------------------------------------------------------------------------------- 1 | context("test-plot_power_oneway_between") 2 | 3 | 4 | 5 | # error messages 6 | test_that("error messages", { 7 | 8 | design_result1 <- ANOVA_design(design = "2b", 9 | n = 100, 10 | mu = c(24,26.2), 11 | sd = 6.4, 12 | plot = FALSE) 13 | 14 | 15 | expect_error(plot_power_oneway_between(), "argument \"design_result\" is missing, with no default" ) 16 | expect_error(plot_power_oneway_between(design_result1), "argument \"max_n\" is missing, with no default" ) 17 | 18 | }) 19 | -------------------------------------------------------------------------------- /mess/old_functions/test-plot_power_oneway_within.R: -------------------------------------------------------------------------------- 1 | context("test-plot_power_oneway_within") 2 | 3 | 4 | 5 | # error messages 6 | test_that("error messages", { 7 | 8 | design_result1 <- ANOVA_design(design = "2w", 9 | n = 100, 10 | mu = c(24,26.2), 11 | sd = 6.4, 12 | r= 0.5, 13 | plot = FALSE) 14 | 15 | expect_error(plot_power_oneway_within(), "argument \"design_result\" is missing, with no default" ) 16 | expect_error(plot_power_oneway_within(design_result1), "argument \"max_n\" is missing, with no default" ) 17 | 18 | }) 19 | -------------------------------------------------------------------------------- /mess/old_functions/test-plot_power_twoway_between.R: -------------------------------------------------------------------------------- 1 | context("test-plot_power_twoway_between") 2 | 3 | 4 | 5 | # error messages 6 | test_that("error messages", { 7 | 8 | design_result1 <- ANOVA_design(design = "2b*2b", 9 | n = 100, 10 | mu = c(24,26,25,27), 11 | sd = 6.4, 12 | plot = FALSE) 13 | 14 | 15 | expect_error(plot_power_twoway_between(), "argument \"design_result\" is missing, with no default" ) 16 | expect_error(plot_power_twoway_between(design_result1), "argument \"max_n\" is missing, with no default" ) 17 | 18 | }) 19 | -------------------------------------------------------------------------------- /mess/old_functions/test-power_2x2_within.R: -------------------------------------------------------------------------------- 1 | context("test-power_2x2_within") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | 7 | expect_error(power_2x2_within(), "argument \"design_result\" is missing, with no default" ) 8 | 9 | design_result1 <- ANOVA_design(design = "2b*2b*2w", 10 | n = 100, 11 | mu = c(24, 26.2, 27, 28, 12 | 24, 26.2, 27, 28), 13 | sd = 6.4, 14 | plot = FALSE) 15 | 16 | 17 | 18 | expect_error(power_2x2_within(design_result1), "Only 2x2 within designs allowed for this function") 19 | 20 | design_result2 <- ANOVA_design(design = "2w*2b", 21 | n = 100, 22 | mu = c(24, 26.2, 27, 28), 23 | sd = 6.4, 24 | r=0.5, 25 | plot = FALSE) 26 | 27 | expect_error(power_2x2_within(design_result2), "Only 2x2 within designs allowed for this function") 28 | 29 | }) 30 | 31 | #Function check ###function not working yet 32 | #test_that("2x2 design", { 33 | 34 | #From ANOVA_power_simulation validation file https://github.com/Lakens/ANOVA_power_simulation/blob/master/validation_files/3.2_validation_power_within_within_2x2_Amsel.md 35 | 36 | # design_result <- ANOVA_design(design = "2w*2w", 37 | # n = 25, 38 | # mu = c(700, 670, 670, 700), 39 | # sd = 150, 40 | # r = 0.75) 41 | 42 | 43 | # power <- power_2x2_within(design_result) 44 | 45 | 46 | 47 | # expect_equal(c(power$power_A,power$power_A,power$power_AB), c(.05,.05,.49), tolerance = .01) 48 | # 49 | #}) 50 | -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if(requireNamespace('spelling', quietly = TRUE)) 2 | spelling::spell_check_test(vignettes = TRUE, error = FALSE, 3 | skip_on_cran = TRUE) 4 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(Superpower) 3 | 4 | 5 | test_check("Superpower") 6 | -------------------------------------------------------------------------------- /tests/testthat/test-ANOVA_compromise.R: -------------------------------------------------------------------------------- 1 | context("test-ANOVA_compromise") 2 | hush=function(code){ 3 | sink("NUL") # use /dev/null in UNIX 4 | tmp = code 5 | sink() 6 | return(tmp) 7 | } 8 | # error messages 9 | test_that("error messages", { 10 | design <- ANOVA_design(design = "2b*4w", 11 | n = 7, 12 | mu = c(0,0,0,0,0.5,0.5,0.5,0.5), 13 | sd = 1, 14 | plot = FALSE) 15 | 16 | expect_error(ANOVA_compromise()) 17 | 18 | }) 19 | 20 | 21 | test_that("example #1 2w",{ 22 | design_result <- ANOVA_design(design = "2b", 23 | n = 100, 24 | mu = c(1:2), 25 | sd = 2, 26 | plot = FALSE) 27 | res = ANOVA_compromise(design_result) 28 | expect_equal(res$aov_comp$alpha,.05101,tolerance = .001) 29 | expect_equal(res$aov_comp$beta,.05853,tolerance = .001) 30 | 31 | design_result <- ANOVA_design(design = "2b", 32 | n = 100, 33 | mu = c(1:2), 34 | sd = 2, 35 | plot = FALSE) 36 | res = ANOVA_compromise(design_result, 37 | liberal_lambda = TRUE) 38 | expect_equal(res$aov_comp$alpha,.05101,tolerance = .001) 39 | expect_equal(res$aov_comp$beta,.05853,tolerance = .005) # larger error margin with liberal lambda 40 | p = plot(res) 41 | pr = hush(print(res)) 42 | }) 43 | 44 | test_that("example #2 2w",{ 45 | skip_on_cran() 46 | design_result <- ANOVA_design(design = "2w", 47 | n = 50, 48 | mu = c(1:2), 49 | sd = 2, 50 | plot = FALSE, 51 | r = .5) 52 | res = ANOVA_compromise(design_result, 53 | liberal_lambda = FALSE) 54 | res2 <- optimal_alpha(power_function = "power.t.test(delta = 1, sd = 2, n = 50, 55 | sig.level = x, type = 'paired', alternative = 'two.sided')$power", 56 | plot = FALSE, 57 | error = "balance") 58 | expect_equal(res$aov_comp$alpha,res2$alpha,tolerance = .01) 59 | expect_equal(res$aov_comp$beta,res2$beta,tolerance = .01) 60 | 61 | res = ANOVA_compromise(design_result, 62 | liberal_lambda = TRUE) 63 | expect_equal(res$aov_comp$alpha,.05101,tolerance = .01) 64 | expect_equal(res$aov_comp$beta,.05853,tolerance = .01) 65 | }) 66 | 67 | test_that("example #3 emmeans",{ 68 | design_result <- ANOVA_design(design = "2w", 69 | n = 50, 70 | mu = c(1:2), 71 | sd = 2, 72 | plot = FALSE, 73 | r = .5) 74 | res = ANOVA_compromise(design_result, 75 | liberal_lambda = FALSE, 76 | emm = TRUE) 77 | res2 <- optimal_alpha(power_function = "power.t.test(delta = 1, sd = 2, n = 50, 78 | sig.level = x, type = 'paired', alternative = 'two.sided')$power", 79 | plot = FALSE, 80 | error = "balance") 81 | expect_equal(res$emmeans_comp$alpha,res2$alpha,tolerance = .01) 82 | expect_equal(res$emmeans_comp$beta,res2$beta,tolerance = .01) 83 | 84 | res = ANOVA_compromise(design_result, 85 | liberal_lambda = TRUE, 86 | emm = TRUE) 87 | expect_equal(res$emmeans_comp$alpha,.05101,tolerance = .01) 88 | expect_equal(res$emmeans_comp$beta,.05853,tolerance = .01) 89 | }) -------------------------------------------------------------------------------- /tests/testthat/test-emmeans_power.R: -------------------------------------------------------------------------------- 1 | context("test-emmeans_power") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | 7 | expect_error(emmeans_power(), "argument \"x\" is missing, with no default") 8 | 9 | 10 | }) 11 | 12 | 13 | 14 | 15 | #2b null 16 | test_that("2b null", { 17 | design <- ANOVA_design(design = "2b", n = 100, mu = c(0, 0), sd = 1, plot = FALSE) 18 | p <- ANOVA_exact(design, emm = TRUE, verbose = FALSE) 19 | 20 | expect_equal(p$main_results$power, 5) 21 | expect_equal(p$pc_results$power, 5) 22 | expect_equal(p$emm_results$power, 5) 23 | 24 | }) 25 | 26 | 27 | 28 | 29 | #2b moderate effect 30 | test_that("2b", { 31 | design <- ANOVA_design(design = "2b", n = 22, mu = c(0, 0.65), sd = 1, plot = FALSE) 32 | p <- ANOVA_exact(design, emm = TRUE, verbose = FALSE) 33 | 34 | expect_equal(p$main_results$power, 55.8, tolerance = 0.1) 35 | expect_equal(p$pc_results$power, 55.8, tolerance = 0.1) 36 | expect_equal(p$emm_results$power, 55.8, tolerance = 0.1) 37 | 38 | }) 39 | 40 | 41 | 42 | #4b low power 43 | test_that("4b", { 44 | skip_on_cran() 45 | design <- ANOVA_design(design = "4b", n = 15, 46 | mu = c(0, 0.25, 0.33, 0.44), 47 | sd = 1, plot = FALSE) 48 | p_monte <- ANOVA_power(design, emm = TRUE, verbose = FALSE, 49 | nsims = 1000, seed = 22042020, 50 | emm_p_adjust = "bonferroni") 51 | p <- ANOVA_exact(design, emm = TRUE, verbose = FALSE) 52 | p_bonf <- ANOVA_exact(design, emm = TRUE, verbose = FALSE, 53 | alpha_level = .05/6) 54 | 55 | expect_equal(p$main_results$power, 15, tolerance = 0.1) 56 | expect_equal(p$pc_results$power, 57 | c(10.14,14.08,21.39,5.51,7.94,5.98), 58 | tolerance = 0.1) 59 | expect_equal(p$pc_results$power, 60 | p_monte$pc_results$power, 61 | tolerance = 0.1) 62 | expect_equal(p_monte$emm_results$power, 63 | p_bonf$emm_results$power, 64 | tolerance = 0.1) 65 | 66 | 67 | }) 68 | 69 | 70 | -------------------------------------------------------------------------------- /tests/testthat/test-justifieR.R: -------------------------------------------------------------------------------- 1 | context("test-justifieR") 2 | #library(pwr2ppl) 3 | 4 | 5 | # error messages 6 | test_that("error messages", { 7 | design <- ANOVA_design(design = "2b*4w", 8 | n = 7, 9 | mu = c(0,0,0,0,0.5,0.5,0.5,0.5), 10 | sd = 1, 11 | plot = FALSE) 12 | 13 | expect_error(optimal_alpha()) 14 | expect_error(power_standardized_alpha()) 15 | expect_error(p_standardized()) 16 | expect_error(alpha_standardized()) 17 | 18 | 19 | }) 20 | 21 | 22 | test_that("optimal_alpha",{ 23 | res <- optimal_alpha(power_function = "power.t.test(delta = .5, sd = 1, n = 100, 24 | sig.level = x, type = 'two.sample', alternative = 'two.sided')$power", 25 | plot = FALSE) 26 | expect_equal(res$alpha, .05101, tolerance = .001) 27 | expect_equal(res$beta, .05853, tolerance = .001) 28 | 29 | skip_on_cran() 30 | res <- optimal_alpha(power_function = "power.t.test(delta = .656, sd = 1, n = 50, 31 | sig.level = x, type = 'two.sample', alternative = 'two.sided')$power", 32 | plot = FALSE, 33 | error = "balance") 34 | expect_equal(res$alpha, .0725, tolerance = .001) 35 | expect_equal(res$beta, .0725, tolerance = .001) 36 | 37 | res <- optimal_alpha(power_function = "power.ftest(num_df = 1, 38 | den_df = 15, 39 | cohen_f = .28, 40 | alpha_level = x)$power/100", 41 | plot = FALSE) 42 | 43 | }) 44 | 45 | test_that("power_standardized_alpha",{ 46 | res <- power_standardized_alpha(power_function = "power.t.test(delta = .3, 47 | sd = 1, n = x, sig.level = a_stan, type = 'two.sample', 48 | alternative = 'two.sided')$power", 49 | power = 0.9, alpha = 0.05, 50 | verbose = FALSE) 51 | expect_equal(res$N, 265) 52 | 53 | }) 54 | 55 | test_that("power_standardized_alpha",{ 56 | res <- power_standardized_alpha(power_function = "power.t.test(delta = .3, 57 | sd = 1, n = x, sig.level = a_stan, type = 'two.sample', 58 | alternative = 'two.sided')$power", 59 | power = 0.9, alpha = 0.05, 60 | verbose = FALSE) 61 | expect_equal(res$N, 265) 62 | 63 | }) 64 | 65 | test_that("p_standardized",{ 66 | ## Check it yields .05 for N = 100: 67 | res1 = p_standardized(p = 0.05, N = 100) 68 | expect_equal(res1, .05) 69 | ## Check it yields .05 for N = 200, p = 0.03535534: 70 | res2 = p_standardized(p = 0.03535534, N = 200) 71 | expect_equal(res2, 0.05) 72 | ## What is a standardized p-value for p = .05 and N = 200? 73 | res3 = p_standardized(p = 0.05, N = 200) 74 | expect_equal(res3, 0.07071068) 75 | ## You can change the standardization N, repeating the example above: 76 | res4 = p_standardized(p = 0.05, 77 | N = 100, 78 | standardize_N = 200) 79 | expect_equal(res4, 0.03535534) 80 | 81 | }) 82 | 83 | test_that("alpha_standardized",{ 84 | ## Check it yields .05 for N = 100: 85 | expect_equal(alpha_standardized(alpha = 0.05, N = 100), .05) 86 | ## Check it yields .05 for N = 200: 87 | expect_equal(alpha_standardized(alpha = 0.07071068, N = 200), .05) 88 | ## Which alpha should we use with N = 200? 89 | expect_equal(alpha_standardized(alpha = 0.05, N = 200),0.03535534) 90 | ## You can change the standardization N, repeating the example above: 91 | expect_equal(alpha_standardized(alpha = 0.05, N = 100, standardize_N = 200),0.07071068) 92 | }) 93 | 94 | -------------------------------------------------------------------------------- /tests/testthat/test-mu_from_ES.R: -------------------------------------------------------------------------------- 1 | context("test-mu_from_ES") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | expect_error(mu_from_ES(K=11, ES=0.05), "Number of levels (k) must be 2, 3, or 4", fixed = TRUE) 7 | expect_error(mu_from_ES(K=3, ES=5), "the ES (partial eta squared) must be less than 1 and greater than zero", fixed = TRUE) 8 | expect_error(mu_from_ES(), "argument \"ES\" is missing, with no default" ) 9 | 10 | expect_error(mu_from_ES(K=3, ES=1.1)) 11 | 12 | }) 13 | 14 | #Function check 15 | test_that("2b and 3b", { 16 | expect_equal(mu_from_ES(K=2, ES=0.0503911)*6.4, c(-1.474295, 1.474295), tolerance = .001) #example from validation files 17 | expect_equal(mu_from_ES(K=3, ES=0.07928127)*6.4, c(-2.300104, 0.00000, 2.300104), tolerance = .001) #example from validation files 18 | expect_equal(mu_from_ES(K=4, ES=.5),c(-1,-1,1,1)) 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-power_oneway_between.R: -------------------------------------------------------------------------------- 1 | context("test-power_oneway_between") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | design <- "2b" 7 | n <- 100 8 | mu <- c(24, 26.2) 9 | sd <- 6.4 10 | 11 | design_result <- ANOVA_design(design = design, 12 | n = n, 13 | mu = mu, 14 | sd = sd, 15 | plot = FALSE) 16 | 17 | 18 | expect_error(power_oneway_between(), "argument \"design_result\" is missing, with no default" ) 19 | 20 | }) 21 | 22 | #Function check 23 | test_that("2b and 3b", { 24 | 25 | design_result1 <- ANOVA_design(design = "2b", 26 | n = 100, 27 | mu = c(24,26.2), 28 | sd = 6.4, plot = FALSE) 29 | 30 | expect_equal(power_oneway_between(design_result1, alpha_level = 0.05)$power, 31 | pwr::pwr.t.test(d = 2.2/6.4, 32 | n = 100, 33 | sig.level = 0.05, 34 | type="two.sample", 35 | alternative="two.sided")$power*100, 36 | tolerance = .001) #example from validation files 37 | 38 | design_result2 <- ANOVA_design(design = "3b", 39 | n = 50, 40 | mu = c(24, 26.2, 26.6), 41 | sd = 6.4, plot = FALSE) 42 | expect_equal(power_oneway_between(design_result2, alpha_level = 0.05)$power, 43 | pwr::pwr.anova.test(n = 50, 44 | k = 3, 45 | f = 0.1786086, #From Gpower 46 | sig.level = .05)$power*100, 47 | tolerance = .001) #example from validation files 48 | }) 49 | -------------------------------------------------------------------------------- /tests/testthat/test-power_oneway_within.R: -------------------------------------------------------------------------------- 1 | context("test-power_oneway_within") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | 7 | expect_error(power_oneway_within(), "argument \"design_result\" is missing, with no default" ) 8 | 9 | }) 10 | 11 | #Function check 12 | test_that("2w and 3w", { 13 | K <- 2 14 | n <- 34 15 | sd <- 1 16 | r <- 0.5 17 | alpha = 0.05 18 | f <- 0.25 19 | f2 <- f^2 20 | ES <- f2/(f2+1) 21 | 22 | mu <- mu_from_ES(K = K, ES = ES) 23 | 24 | design = paste(K,"w",sep="") 25 | 26 | design_result1 <- ANOVA_design(design = design, 27 | n = n, 28 | mu = mu, 29 | sd = sd, 30 | r = r, plot = FALSE) 31 | 32 | expect_equal(power_oneway_within(design_result1, alpha_level = 0.05)$power, 33 | pwr::pwr.t.test(d = 0.5, 34 | n = 34, 35 | sig.level = 0.05, 36 | type = "paired", 37 | alternative = "two.sided")$power*100, 38 | tolerance = .001) #example from validation files 39 | 40 | K <- 3 41 | n <- 20 42 | sd <- 1 43 | r <- 0.8 44 | f <- 0.25 45 | f2 <- f^2 46 | ES <- f2 / (f2 + 1) 47 | mu <- mu_from_ES(K = K, ES = ES) 48 | design = paste(K,"w",sep = "") 49 | 50 | design_result2 <- ANOVA_design(design = design, 51 | n = n, 52 | mu = mu, 53 | sd = sd, 54 | r = r, plot = FALSE) 55 | 56 | #Formula used by G*Power for within design 57 | f <- 0.25 #Cohen's f 58 | k <- 1 #number of groups 59 | m <- 3 #number of measures 60 | n <- 20 #total sample size 61 | e <- 1 #non-spericity correction 62 | r <- 0.8 #correlation between dependent variables 63 | alpha <- 0.05 #alpha level 64 | 65 | df1 <- (m - 1) * e #calculate degrees of freedom 1 66 | df2 <- (n - k) * (m - 1) * e #calculate degrees of freedom 2 67 | 68 | lambda <- (n * m * f^2) / (1 - r) # lambda for within ANOVA 69 | 70 | F_critical <- qf(alpha, # critical F-vaue 71 | df1, 72 | df2, 73 | lower.tail = FALSE) 74 | 75 | pow <- pf(qf(alpha, #power 76 | df1, 77 | df2, 78 | lower.tail = FALSE), 79 | df1, 80 | df2, 81 | lambda, 82 | lower.tail = FALSE) 83 | 84 | 85 | expect_equal(power_oneway_within(design_result2, alpha_level = 0.05)$power, 86 | pow*100, 87 | tolerance = .01) #example from validation files 88 | }) 89 | -------------------------------------------------------------------------------- /tests/testthat/test-power_threeway_between.R: -------------------------------------------------------------------------------- 1 | context("test-power_threeway_between") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | 7 | expect_error(power_twoway_between(), "argument \"design_result\" is missing, with no default" ) 8 | 9 | design_result1 <- ANOVA_design(design = "2b*2b*2w", 10 | n = 100, 11 | mu = c(24, 26.2, 27, 28, 12 | 24, 26.2, 27, 28), 13 | sd = 6.4, 14 | plot = FALSE) 15 | 16 | 17 | 18 | expect_error(power_threeway_between(design_result1), "Only three-way between designs allowed for this function") 19 | 20 | design_result2 <- ANOVA_design(design = "2b*2b", 21 | n = 100, 22 | mu = c(24, 26.2, 27, 28), 23 | sd = 6.4, 24 | plot = FALSE) 25 | 26 | expect_error(power_threeway_between(design_result2), "Only three-way between designs allowed for this function") 27 | 28 | }) 29 | 30 | #Function check 31 | test_that("3-way design", { 32 | 33 | #From ANOVA_power_simulation validation file https://github.com/Lakens/ANOVA_power_simulation/blob/master/validation_files/4.6_threeway_interactions.md 34 | 35 | design_result <- ANOVA_design(design = "2b*2b*2b", 36 | n = 50, 37 | mu = c(2, 2, 6, 1, 6, 6, 1, 8), 38 | sd = 10, 39 | plot = FALSE) 40 | 41 | 42 | power <- power_threeway_between(design_result) 43 | 44 | expect_equal(power$power_ABC, 84.9, tolerance = .01) 45 | 46 | }) 47 | -------------------------------------------------------------------------------- /tests/testthat/test-power_twoway_between.R: -------------------------------------------------------------------------------- 1 | context("test-power_twoway_between") 2 | 3 | # error messages 4 | test_that("error messages", { 5 | 6 | design <- "2b*2w" 7 | n <- 100 8 | mu <- c(24, 26.2, 27, 28) 9 | sd <- 6.4 10 | 11 | design_result <- ANOVA_design(design = design, 12 | n = n, 13 | mu = mu, 14 | sd = sd, 15 | plot = FALSE) 16 | 17 | 18 | expect_error(power_twoway_between(), "argument \"design_result\" is missing, with no default" ) 19 | expect_error(power_twoway_between(design_result), "Only two-way between designs allowed for this function") 20 | 21 | }) 22 | 23 | #Function check 24 | test_that("2x2 design", { 25 | 26 | #From Data Colada validation file https://github.com/Lakens/ANOVA_power_simulation/blob/master/validation_files/4.2_power_for_interactions.pdf 27 | design <- "2b*2b" 28 | n <- 150 29 | mu <- c(20, 20, 20, 25) #All means are equal - so there is no real difference. 30 | sd <- 20 31 | labelnames <- c("fruit", "apple", "banana", "hunger", "no hunger", "very hungry") # 32 | # the label names should be in the order of the means specified above. 33 | design_result <- ANOVA_design(design = design, 34 | n = n, 35 | mu = mu, 36 | sd = sd, 37 | labelnames = labelnames, 38 | plot = FALSE) 39 | 40 | 41 | 42 | power <- power_twoway_between(design_result) 43 | expect_equal(c(power$power_A, power$power_B, power$power_AB), c(33,33,33), tolerance = .5) 44 | 45 | }) 46 | -------------------------------------------------------------------------------- /tests/testthat/test_sim_cor.R: -------------------------------------------------------------------------------- 1 | context("Simulated Data") 2 | library(Superpower) 3 | library(reshape2) 4 | 5 | test_that("simulated correlations fit expected values", { 6 | design_result <- ANOVA_design(design = "2b*2w", 7 | n = 1000000, 8 | mu = c(0, 0, 0, 0), 9 | sd = 2, 10 | r = 0.8, 11 | labelnames = c("condition", "cheerful", "sad", "voice", "human", "robot"), 12 | plot = FALSE) 13 | 14 | design_result$cor_mat 15 | 16 | data_wide <- dcast(design_result$dataframe, subject ~ cond, value.var="y") 17 | a1 <- data_wide[,2][!is.na(data_wide[,2])] 18 | a2 <- data_wide[,3][!is.na(data_wide[,3])] 19 | b1 <- data_wide[,4][!is.na(data_wide[,4])] 20 | b2 <- data_wide[,5][!is.na(data_wide[,5])] 21 | 22 | res1 <- cor(a1, a2) 23 | res2 <- cor(a1, b1) 24 | res3 <- cor(a1, b2) 25 | res4 <- cor(a2, b1) 26 | res5 <- cor(a2, b2) 27 | res6 <- cor(b1, b2) 28 | 29 | res1i <- cor(a1, a1) 30 | res2i <- cor(a2, a2) 31 | res3i <- cor(b1, b1) 32 | res4i <- cor(b2, b2) 33 | 34 | expect_equal(res1, 0.8, tolerance = .003) 35 | expect_equal(res2, 0, tolerance = .003) 36 | expect_equal(res3, 0, tolerance = .003) 37 | expect_equal(res4, 0, tolerance = .003) 38 | expect_equal(res5, 0, tolerance = .003) 39 | expect_equal(res6, 0.8, tolerance = .003) 40 | expect_equal(res1i, 1, tolerance = .003) 41 | expect_equal(res2i, 1, tolerance = .003) 42 | expect_equal(res3i, 1, tolerance = .003) 43 | expect_equal(res4i, 1, tolerance = .003) 44 | }) 45 | 46 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/refs.json: -------------------------------------------------------------------------------- 1 | [{"id":"shieh_ancova","author":[{"family":"Shieh","given":"G."}], 2 | "title":"Power analysis and sample size planning in ANCOVA designs", 3 | "volume":"85","type":"article-journal", 4 | "container-title":"Psychometrika", 5 | "issue":"1","language":"sv", 6 | "issued":{"date-parts":[[2020]]}, 7 | "page":"101–120", 8 | "URL":"https://doi.org/10.1007/s11336-019-09692-3","DOI":"10.1007/s11336-019-09692-3"}, 9 | {"id":"cohen_book","author":[{"family":"Cohen","given":"J."}],"title":"Statistical Power Analysis for the Behavioral Sciences","edition":"2nd","note":"Routledge.","language":"en","type":"book","issued":{"date-parts":[[1988]]},"URL":"https://doi.org/10.4324/9780203771587","DOI":"10.4324/9780203771587"}, 10 | {"id":"maxwell_delaney","author":[{"family":"Maxwell","given":"S.E."},{"family":"Delaney","given":"H.D."}],"title":"Designing experiments and analyzing data: A model comparison perspective","edition":"2nd","publisher":"Lawrence Erlbaum Associates","language":"en","type":"book","issued":{"date-parts":[[2004]]},"publisher-place":"Mahwah, NJ"}] -------------------------------------------------------------------------------- /vignettes/screenshots/PS2000.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/PS2000.gif -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_1.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_10.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_11.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_12.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_14.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_5.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_6.png -------------------------------------------------------------------------------- /vignettes/screenshots/gpower_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/screenshots/gpower_9.png -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_cross_40.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_cross_40.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_cross_80.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_cross_80.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_ordinal.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_ordinal.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_vig_1.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_vig_1.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_vig_2.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_vig_2.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_vig_3.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_vig_3.rds -------------------------------------------------------------------------------- /vignettes/sim_data/power_result_vig_4.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/power_result_vig_4.rds -------------------------------------------------------------------------------- /vignettes/sim_data/vig_1_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arcaldwell49/Superpower/5d7da2af9a4e3d19fad6c1aad535a7f1ec1003ed/vignettes/sim_data/vig_1_plot.png --------------------------------------------------------------------------------