Description Usage Arguments Details Value References Examples
View source: R/retrospective.R
Given the hypothetical population effect size and the study sample size, the
function retrospective()
performs a retrospective design analysis for
Pearson's correlation test between two variables or t-test comparing
group means (Cohen's d). According to the defined alternative
hypothesis and the significance level, inferential risks (i.e., Power level,
Type M error, and Type S error) are computed together with the critical
effect value (i.e., the minimum absolute effect size value that would result
significant).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | retrospective(
effect_size,
sample_n1,
sample_n2 = NULL,
effect_type = c("correlation", "cohen_d"),
test_method = c("pearson", "two_sample", "welch", "paired", "one_sample"),
alternative = c("two_sided", "less", "greater"),
sig_level = 0.05,
ratio_sd = 1,
B = 10000,
tl = -Inf,
tu = Inf,
B_effect = 1000,
seed = NULL
)
|
effect_size |
a numeric value or function (see details) indicating the hypothetical population effect size. |
sample_n1 |
a numeric value indicating the sample size of the first group. |
sample_n2 |
an optional numeric value indicating the sample size of the second group. |
effect_type |
a character string specifying the effect type, must be one
of |
test_method |
a character string specifying the test type, must be one of
|
alternative |
a character string specifying the alternative hypothesis,
must be one of |
sig_level |
a numeric value indicating the significance level on which the alternative hypothesis is evaluated. |
ratio_sd |
a numeric value indicating the ratio between the standard deviation in the first group and in the second group. This argument is needed in the case of Welch's t-test. |
B |
a numeric value indicating the number of iterations. Increase the number of iterations to obtain more stable results. |
tl |
optional value indicating the lower truncation point if
|
tu |
optional value indicating the upper truncation point if
|
B_effect |
a numeric value indicating the number of sampled effects
if |
seed |
a numeric value indicating the seed for random number generation. Set the seed to obtain reproducible results. |
Conduct a retrospective design analysis to evaluate inferential risks
according to study design. A general overview is provided in the
vignette("retrospective")
.
Population effect size
The hypothetical population effect size (effect_size
) can be set to a
single value or a function that allows sampling values from a given
distribution. The function has to be defined as function(x)
my_function(x, ...)
, with only one single argument x
representing
the number of sampled values (e.g., function(x) rnorm(x, mean = 0, sd
= 1)
; function(x) sample(c(.1,.3,.5), x, replace = TRUE)
). This
allows users to define hypothetical effect size distribution according to
their needs.
Argument B_effect
allows defining the number of sampled effects.
Users can access sampled effects in the effect_info
list included in
the output to evaluate if the sample is representative of their
specification. Increase the number to obtain more accurate results but it
will require more computational time (default is 1000). To avoid long
computational times, we suggest adjusting B
when using a function to
define the hypothetical population effect size.
Optional arguments tl
and tu
allow truncating the sampling
distribution specifying the lower truncation point and upper truncation
point respectively. Note that if effect_type = "correlation"
,
distribution is automatically truncated between -1 and 1.
Effect type and test method options
The effect_type
argument can be set to "correlation"
(default)
if a correlation is evaluated or "cohen_d"
for standardized mean
difference.
In the case of "correlation"
, only Pearson's correlation between two
variables is available. In this case "pearson"
has to be set as
test_method
and sample_n2
argument is ignored. The
Kendall's tau and Spearman's rho are not implemented.
In the case of "cohen_d"
, the available t-tests can be
selected specifying the argument test_method
. For independent
two-sample t-test, use "two_sample"
and indicate the sample
size of the second group (sample_n2
). For Welch's t-test, use
"welch"
and indicate and indicate the sample size of the second group
(sample_n2
) and the ratio between the standard deviation in the first
group and in the second group (ratio_sd
). For dependent t-test
for paired samples, use "paired"
(sample_n1
and
sample_n2
have to be equal). For one-sample t-test, use
"one_sample"
(sample_n2
has to be NULL
).
Study design
Study design can be further defined according to statistical test
directionality and required α-level using the arguments
alternative
and sig_level
respectively.
A list with class "design_analysis" containing the following components:
design_analysis |
a character string indicating the type of design analysis: "retrospective". |
call_arguments |
a list with all the arguments passed to the function. |
effect_info |
a list with all the information regarding the
considered hypothetical population effect size. The list includes:
|
test_info |
a list with all the information regarding the test
performed. The list includes: |
retrospective_res |
a data frame with the results of the design
analysis. Columns names are |
Altoè, G., Bertoldo, G., Zandonella Callegher, C., Toffalini, E., Calcagnì, A., Finos, L., & Pastore, M. (2020). Enhancing Statistical Inference in Psychological Research via Prospective and Retrospective Design Analysis. Frontiers in Psychology, 10. https://doi.org/10.3389/fpsyg.2019.02893
Bertoldo, G., Altoè, G., & Zandonella Callegher, C. (2020). Designing Studies and Evaluating Research Results: Type M and Type S Errors for Pearson Correlation Coefficient. Retrieved from https://psyarxiv.com/q9f86/
Gelman, A., & Carlin, J. (2014). Beyond Power Calculations: Assessing Type S (Sign) and Type M (Magnitude) Errors. Perspectives on Psychological Science, 9(6), 641–651. https://doi.org/10.1177/1745691614551642
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Pearson's correlation
retrospective(effect_size = .3, sample_n1 = 25, effect_type = "correlation",
test_method = "pearson", seed = 2020)
# Two-sample t-test
retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 35,
effect_type = "cohen_d", test_method = "two_sample",
seed = 2020)
# Welch t-test
retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 35,
effect_type = "cohen_d", test_method = "welch",
ratio_sd = 1.5, seed = 2020)
# Paired t-test
retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 25,
effect_type = "cohen_d", test_method = "paired", seed = 2020)
# One-sample t-test
retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = NULL,
effect_type = "cohen_d", test_method = "one_sample",
seed = 2020)
## Not run:
# Define effect_size using functions (long computational times)
# Remember to adjust B
retrospective(effect_size = function(x) rnorm(x, .3, .1), sample_n1 = 25,
effect_type = "correlation", est_method = "pearson",
tl = .15, B = 1e3, seed = 2020)
retrospective(effect_size = function(x) rnorm(x, .3, .1), sample_n1 = 25,
effect_type = "cohen_d", est_method = "one_sample",
tl = .2, tu = .4, B = 1e3, seed = 2020)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.