Title: | Justifying Alpha Levels for Hypothesis Tests |
---|---|
Description: | Functions to justify alpha levels for statistical hypothesis tests by avoiding Lindley's paradox, or by minimizing or balancing error rates. For more information about the package please read the following: Maier & Lakens (2021) <doi:10.31234/osf.io/ts4r6>). |
Authors: | Maximilian Maier [aut, cre], Daniel Lakens [aut] |
Maintainer: | Maximilian Maier <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-18 06:29:39 UTC |
Source: | CRAN |
Justify your alpha level by avoiding the Lindley paradox or aiming for moderate or strong evidence when using anova.
ftestEvidence(evidence, df1, df2, paired = FALSE, printplot = FALSE)
ftestEvidence(evidence, df1, df2, paired = FALSE, printplot = FALSE)
evidence |
Desired level of evidence: "Lindley" to avoid the Lindley Paradox, "moderate" to achieve moderate evidence and "strong" to achieve strong evidence. Users that are more familiar with Bayesian statistics can also directly enter their desired Bayes factor. |
df1 |
Numerator degrees of freedom. |
df2 |
Denominator degrees of freedom. |
paired |
If true a within subjects design is assumed. |
printplot |
If true prints a plot relating Bayes factors and p-values. |
numeric alpha level required to avoid Lindley's paradox.
Maier & Lakens (2021). Justify Your Alpha: A Primer on Two Practical Approaches
## Avoid the Lindley paradox for an anova with 1 numerator and 248 denominator degrees of freedom. ftestEvidence("lindley", 1, 248)
## Avoid the Lindley paradox for an anova with 1 numerator and 248 denominator degrees of freedom. ftestEvidence("lindley", 1, 248)
Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates.
optimal_alpha( power_function, costT1T2 = 1, priorH1H0 = 1, error = "minimize", verbose = FALSE, printplot = FALSE )
optimal_alpha( power_function, costT1T2 = 1, priorH1H0 = 1, error = "minimize", verbose = FALSE, printplot = FALSE )
power_function |
Function that outputs the power, calculated with an analytic function. |
costT1T2 |
Relative cost of Type 1 errors vs. Type 2 errors. |
priorH1H0 |
How much more likely a-priori is H1 than H0? |
error |
Either "minimize" to minimize error rates, or "balance" to balance error rates. |
verbose |
Print each iteration of the optimization function if TRUE. Defaults to FALSE. |
printplot |
Print a plot to illustrate the alpha level calculation. |
Returns a list of the following alpha = alpha or Type 1 error that minimizes or balances combined error rates, beta = beta or Type 2 error that minimizes or balances combined error rates, errorrate = weighted combined error rate, objective = value that is the result of the minimization, either 0 (for balance) or the combined weighted error rates. plot_data = data used for plotting (only if printplot = TRUE) plot = plot of error rates depending on alpha (only if printplot = TRUE)
Maier & Lakens (2021). Justify Your Alpha: A Primer on Two Practical Approaches
## Optimize power for a independent t-test, smallest effect of interest ## d = 0.5, 100 participants per condition res <- optimal_alpha(power_function = "pwr::pwr.t.test(d = 0.5, n = 100, sig.level = x, type = 'two.sample', alternative = 'two.sided')$power") res$alpha res$beta res$errorate
## Optimize power for a independent t-test, smallest effect of interest ## d = 0.5, 100 participants per condition res <- optimal_alpha(power_function = "pwr::pwr.t.test(d = 0.5, n = 100, sig.level = x, type = 'two.sample', alternative = 'two.sided')$power") res$alpha res$beta res$errorate
Justify your alpha level by minimizing or balancing Type 1 and Type 2 error rates.
optimal_sample( power_function, errorgoal = 0.05, costT1T2 = 1, priorH1H0 = 1, error = "minimize", printplot = FALSE )
optimal_sample( power_function, errorgoal = 0.05, costT1T2 = 1, priorH1H0 = 1, error = "minimize", printplot = FALSE )
power_function |
Function that outputs the power, calculated with an analytic function. |
errorgoal |
Desired weighted combined error rate |
costT1T2 |
Relative cost of Type 1 errors vs. Type 2 errors. |
priorH1H0 |
How much more likely a-priori is H1 than H0? |
error |
Either "minimize" to minimize error rates, or "balance" to balance error rates. |
printplot |
Print a plot to illustrate the alpha level calculation. This will make the function considerably slower. |
Returns a list of the following alpha = alpha or Type 1 error that minimizes or balances combined error rates, beta = beta or Type 2 error that minimizes or balances combined error rates, errorrate = weighted combined error rate, objective = value that is the result of the minimization, either 0 (for balance) or the combined weighted error rates, samplesize = the desired samplesize. plot = plot of alpha, beta, and error rate as a function of samplesize (only if printplot = TRUE)
Maier & Lakens (2021). Justify Your Alpha: A Primer on Two Practical Approaches
## Optimize power for a independent t-test, smallest effect of interest ## d = 0.5, desired weighted combined error rate = 5% res <- optimal_sample(power_function = "pwr::pwr.t.test(d = 0.5, n = sample_n, sig.level = x, type = 'two.sample', alternative = 'two.sided')$power",errorgoal = 0.05) res$alpha res$beta res$errorrate res$samplesize
## Optimize power for a independent t-test, smallest effect of interest ## d = 0.5, desired weighted combined error rate = 5% res <- optimal_sample(power_function = "pwr::pwr.t.test(d = 0.5, n = sample_n, sig.level = x, type = 'two.sample', alternative = 'two.sided')$power",errorgoal = 0.05) res$alpha res$beta res$errorrate res$samplesize
Launch the Justify your alpha shiny app.
runApp()
runApp()
Justify your alpha level by avoiding the Lindley paradox or aiming for moderate or strong evidence when using a t-test.
ttestEvidence( evidence, n1, n2 = 0, one.sided = FALSE, rscale = sqrt(2)/2, printplot = FALSE )
ttestEvidence( evidence, n1, n2 = 0, one.sided = FALSE, rscale = sqrt(2)/2, printplot = FALSE )
evidence |
Desired level of evidence: "Lindley" to avoid the Lindley Paradox, "moderate" to achieve moderate evidence and "strong" to achieve strong evidence. Users that are more familiar with Bayesian statistics can also directly enter their desired Bayes factor. |
n1 |
Sample size in Group 1. |
n2 |
Sample size in Group 2. Leave blank for a one-sample or paired-sample |
one.sided |
Indicates whether the test is one sided or two sided. |
rscale |
Scale of the Cauchy prior |
printplot |
If true prints a plot relating Bayes factors and p-values. |
numeric alpha level required to avoid Lindley's paradox.
Maier & Lakens (2021). Justify Your Alpha: A Primer on Two Practical Approaches
## Avoid the Lindley paradox for a two sample t-test with 300 participants per condition ttestEvidence("lindley", 300, 300)
## Avoid the Lindley paradox for a two sample t-test with 300 participants per condition ttestEvidence("lindley", 300, 300)