Title: | Tools for Type S (Sign) and Type M (Magnitude) Errors |
---|---|
Description: | Provides tools for working with Type S (Sign) and Type M (Magnitude) errors, as proposed in Gelman and Tuerlinckx (2000) <doi:10.1007/s001800000040> and Gelman & Carlin (2014) <doi:10.1177/1745691614551642>. In addition to simply calculating the probability of Type S/M error, the package includes functions for calculating these errors across a variety of effect sizes for comparison, and recommended sample size given "tolerances" for Type S/M errors. To improve the speed of these calculations, closed forms solutions for the probability of a Type S/M error from Lu, Qiu, and Deng (2018) <doi:10.1111/bmsp.12132> are implemented. As of 1.0.0, this includes support only for simple research designs. See the package vignette for a fuller exposition on how Type S/M errors arise in research, and how to analyze them using the type of design analysis proposed in the above papers. |
Authors: | Andrew Timm [cre, aut], Andrew Gelman [ctb, cph], John Carlin [ctb, cph], Martijn Weterings [ctb] |
Maintainer: | Andrew Timm <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.2 |
Built: | 2025-02-18 06:12:54 UTC |
Source: | https://github.com/andytimm/retrodesign |
This function name is deprecated in favor of the more clearly named retro_design_closed_form; it won't be removed in any hurry, just trying to move the naming conventions to be clearer and easier to use.
retro_design(A, s, alpha = 0.05)
retro_design(A, s, alpha = 0.05)
A |
a numeric or list, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
Calculates Power, Type S, and Type M error and returns them in a list or df, depending on whether a single true effect size or range is provided. Uses the closed form solution found for the Type-M error found by Lu et al. (2018), and thus is faster than retrodesign. For t distributions, use retrodesign() instead; the closed form solution only applies in the normal case.
either a list of length 3 containing the power, type s, and type M error, or if A is a list, a df that is 4 by length(A), with an effect size and it's corresponding power, type s, and type m errors in each row.
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1)
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1)
Calculates Power, Type S, and Type M error and returns them in a list or df, depending on whether a single true effect size or range is provided. Uses the closed form solution found for the Type-M error found by Lu et al. (2018), and thus is faster than retrodesign. For t distributions, use retrodesign() instead; the closed form solution only applies in the normal case.
retro_design_closed_form(A, s, alpha = 0.05)
retro_design_closed_form(A, s, alpha = 0.05)
A |
a numeric or list, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
either a list of length 3 containing the power, type s, and type M error, or if A is a list, a df that is 4 by length(A), with an effect size and it's corresponding power, type s, and type m errors in each row.
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1)
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1)
retro_design_closed_form.list is the S3 method of the generic retro_design_closed_form() function, used when a list is passed for A.
## S3 method for class 'list' retro_design_closed_form(A, s, alpha = 0.05)
## S3 method for class 'list' retro_design_closed_form(A, s, alpha = 0.05)
A |
a list, estimates of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
A df that is 4 by length(A), with an effect size and it's corresponding power, type s, and type m errors in each row.
retro_design(list(.2,2,20),8.1)
retro_design(list(.2,2,20),8.1)
retro_design_closed_form.numeric is the S3 method of the generic retro_design_closed_form() function, used when a single numeric is passed for A.
## S3 method for class 'numeric' retro_design_closed_form(A, s, alpha = 0.05)
## S3 method for class 'numeric' retro_design_closed_form(A, s, alpha = 0.05)
A |
a numeric, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
A list of length 3 containing the power, type s, and type M error.
retrodesign(1,3.28) retrodesign(2,8.1)
retrodesign(1,3.28) retrodesign(2,8.1)
Calculates Power, Type S, and Type M error and returns them in a list or df, depending on whether a single true effect size or range is provided. retro_design() is faster as it uses the closed form solution from Lu et al. (2018), but this function can be used for t distributions, whereas retro_design() cannot. Function originally provided in Gelman and Carlin (2014), modified with permission.
retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
A |
a numeric or list, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error. |
either a list of length 3 containing the power, type s, and type M error, or if A is a list, a df that is 4 by length(A), with an effect size and it's corresponding power, type s, and type m errors in each row.
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1) retrodesign(.5,1,df=10)
retrodesign(1,3.28) retrodesign(list(.2,2,20),8.1) retrodesign(.5,1,df=10)
retrodesign.list is the S3 method of the generic retrodesign() function, used when a list is passed for A.
## S3 method for class 'list' retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
## S3 method for class 'list' retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
A |
a list, estimates of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
A df that is 4 by length(A), with an effect size and it's corresponding power, type s, and type m errors in each row.
retrodesign(list(.2,2,20), 8.1) retrodesign(list(.2,2,20), 8.1,df = 10)
retrodesign(list(.2,2,20), 8.1) retrodesign(list(.2,2,20), 8.1,df = 10)
retrodesign.numeric is the S3 method of the generic retrodesign() function, used when a single numeric is passed for A. Martijn Weterings kindly provided code to slightly improve this in the very low N case using the non-central t-distribution.
## S3 method for class 'numeric' retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
## S3 method for class 'numeric' retrodesign(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
A |
a numeric, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
A list of length 3 containing the power, type s, and type M error.
retrodesign(1,3.28) retrodesign(2,8.1) retrodesign(.5,1,df=10)
retrodesign(1,3.28) retrodesign(2,8.1) retrodesign(.5,1,df=10)
Graphs type S/M errors resulting from a simulation using the provided parameters (using the same simulation method as retrodesign()). Can optionally display using ggplot.
sim_plot(A, s, alpha = 0.05, df = Inf, n.sims = 5000, gg = TRUE)
sim_plot(A, s, alpha = 0.05, df = Inf, n.sims = 5000, gg = TRUE)
A |
a numeric, an estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the degrees of freedom |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
gg |
If TRUE and ggplot2 is installed, uses ggplot2 for graphic |
A list of length 3 containing the power, type s, and type M error.
sim_plot(1,3.28) sim_plot(.5,1)
sim_plot(1,3.28) sim_plot(.5,1)
Calculates type m error. Is calculated using simulation, and thus supports t distributions through the df parameter.
type_m(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
type_m(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
A |
a numeric or list, estimate(s) of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the number of degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
either the type m error, a numeric if a single A is provided, or a df of length 2 by A, with the effect size and corresponding type m error in each row.
type_m(1,3.28) type_m(list(.2,2,20),8.1)
type_m(1,3.28) type_m(list(.2,2,20),8.1)
type_m.list is the S3 method of the generic type_m() function, used when a list is passed for A.
## S3 method for class 'list' type_m(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
## S3 method for class 'list' type_m(A, s, alpha = 0.05, df = Inf, n.sims = 10000)
A |
a list, estimates of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the number of degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
A df that is 2 by length(A), with an effect size and it's corresponding type m errors in each row.
type_s(list(.2,2,20),8.1)
type_s(list(.2,2,20),8.1)
this is the S3 method of the generic type_m() function, used when a numeric is passed for A.
## S3 method for class 'numeric' type_m(A, s, alpha = 0.05, df = Inf, n.sims = 1e+05)
## S3 method for class 'numeric' type_m(A, s, alpha = 0.05, df = Inf, n.sims = 1e+05)
A |
a numeric, estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
df |
a numeric, the number of degrees of freedom. df=Inf is equivalent to a normal distribution. |
n.sims |
a numeric, how many times to simulate when calculating Type M error |
either the type m, a numeric if a single A is provided, or a df of length 2 by A, with the effect size and corresponding type m error in each row.
type_m(1,3.28)
type_m(1,3.28)
Calculates type s error.
type_s(A, s, alpha = 0.05)
type_s(A, s, alpha = 0.05)
A |
a numeric or list, estimate(s) of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
either the type S, a numeric if a single A is provided, or a df of length 2 by A, with the effect size and corresponding type S error in each row.
type_s(1,3.28) type_s(list(.2,2,20),8.1)
type_s(1,3.28) type_s(list(.2,2,20),8.1)
type_s.list is the S3 method of the generic type_s() function, used when a list is passed for A.
## S3 method for class 'list' type_s(A, s, alpha = 0.05)
## S3 method for class 'list' type_s(A, s, alpha = 0.05)
A |
a list, estimates of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
A df that is 2 by length(A), with an effect size and it's corresponding type s errors in each row.
type_s(list(.2,2,20),8.1)
type_s(list(.2,2,20),8.1)
this is the S3 method of the generic type_s() function, used when a numeric is passed for A.
## S3 method for class 'numeric' type_s(A, s, alpha = 0.05)
## S3 method for class 'numeric' type_s(A, s, alpha = 0.05)
A |
a numeric, estimate of the true effect size |
s |
a numeric, standard error of the estimate |
alpha |
a numeric, the statistical significance threshold |
either the type S, a numeric if a single A is provided, or a df of length 2 by A, with the effect size and corresponding type S error in each row.
type_s(1,3.28)
type_s(1,3.28)