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).

retrospective(
  effect_size,
  sample_n1,
  sample_n2 = NULL,
  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,
  display_message = TRUE
)

Arguments

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

a numeric value indicating the sample size of the second group. This argument is required when test_method is set to "two_sample" or "welch". In the case of test_method = "paired", set sample_n2 equal to sample_n1. Whereas in the case of test_method = "one_sample", set sample_n2 to NULL. This argument is ignored for test_method = "pearson". See Test methods section in Details.

test_method

a character string specifying the test type, must be one of "pearson" (default, Pearson's correlation), "two_sample" (independent two-sample t-test), "welch" (Welch's t-test), "paired" (dependent t-test for paired samples), or "one_sample" (one-sample t-test). You can specify just the initial letters.

alternative

a character string specifying the alternative hypothesis, must be one of "two_sided" (default), "greater" or "less". You can specify just the initial letter.

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 effect_size is defined as a function.

tu

optional value indicating the upper truncation point if effect_size is defined as a function.

B_effect

a numeric value indicating the number of sampled effects if effect_size is defined as a function. Increase the number to obtain more stable results.

display_message

a logical variable indicating whether to display or not the progress bar. Not that this applies only when effect_size is defined as a function.

Value

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 and the raw function call.

effect_info

a list with all the information regarding the considered hypothetical population effect size. The list includes: effect_type indicating the type of effect; effect_function indicating the function from which effect are sampled or the string "single_value" if a single value was provided; effect_summary summary of the sampled effects; effect_samples vector with the sampled effects (or unique value in the case of a single value). if relevant tl and tu specifying the lower upper truncation point respectively.

test_info

a list with all the information regarding the test performed. The list includes: test_method character sting indicating the test method (i.e., "pearson", "one_sample", "paired", "two_sample", or "welch"); sample size (sample_n1 and if relevant sample_n2), alternative hypothesis (alternative), significance level (sig_level) and degrees of freedom (df) of the statistical test; critical_effect the minimum absolute effect value that would result significant. Note that critical_effect in the case of alternative = "two_sided" is the absolute value and both positive and negative values should be considered.

retrospective_res

a data frame with the results of the design analysis. Columns names are power, typeM, and typeS.

Details

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(n) my_function(n, ...), with only one single argument n representing the number of sampled values (e.g., function(n) rnorm(n, mean = 0, sd = 1); function(n) sample(c(.1,.3,.5), n, 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.

Test methods

The function retrospective() performs a retrospective design analysis considering correlations between two variables or comparisons between group means.

In the case of a correlation, only Pearson's correlation between two variables is available, whereas Kendall's tau and Spearman's rho are not implemented. The test_method argument has to be set to "pearson" (default) and the effect_size argument is used to define the hypothetical population effect size in terms of Pearson's correlation coefficient (\(\rho\)). The sample_n2 argument is ignored.

In the case of a comparison between group means, the effect_size argument is used to define the hypothetical population effect size in terms of Cohen's d and the available t-tests are 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 \(\alpha\)-level using the arguments alternative and sig_level respectively.

References

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

Examples

# Pearson's correlation retrospective(effect_size = .3, sample_n1 = 25, test_method = "pearson")
#> #> Design Analysis #> #> Hypothesized effect: rho = 0.3 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> pearson 25 NULL two_sided 0.05 23 #> #> Inferential risks: #> power typeM typeS #> 0.313 1.678 0.001 #> #> Critical value(s): rho = ± 0.396
# Two-sample t-test retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 35, test_method = "two_sample")
#> #> Design Analysis #> #> Hypothesized effect: cohen_d = 0.3 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> two_sample 25 35 two_sided 0.05 58 #> #> Inferential risks: #> power typeM typeS #> 0.205 2.243 0.003 #> #> Critical value(s): cohen_d = ± 0.524
# Welch t-test retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 35, test_method = "welch", ratio_sd = 1.5)
#> #> Design Analysis #> #> Hypothesized effect: cohen_d = 0.3 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> welch 25 35 two_sided 0.05 38.89 #> #> Inferential risks: #> power typeM typeS #> 0.183 2.345 0.007 #> #> Critical value(s): cohen_d = ± 0.546
# Paired t-test retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = 25, test_method = "paired")
#> #> Design Analysis #> #> Hypothesized effect: cohen_d = 0.3 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> paired 25 25 two_sided 0.05 24 #> #> Inferential risks: #> power typeM typeS #> 0.298 1.8 0 #> #> Critical value(s): cohen_d = ± 0.413
# One-sample t-test retrospective(effect_size = .3, sample_n1 = 25, sample_n2 = NULL, test_method = "one_sample")
#> #> Design Analysis #> #> Hypothesized effect: cohen_d = 0.3 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> one_sample 25 NULL two_sided 0.05 24 #> #> Inferential risks: #> power typeM typeS #> 0.303 1.873 0.001 #> #> Critical value(s): cohen_d = ± 0.413
# \donttest{ # Define effect_size using functions (long computational times) # Remember to adjust B retrospective(effect_size = function(n) rnorm(n, .3, .1), sample_n1 = 25, test_method = "pearson", tl = .15, B = 1e3)
#> If 'effect_type = correlation', effect_size distribution is truncated between 0.15 and 1
#> Truncation could require long computational time
#> #> Design Analysis #> #> Hypothesized effect: rho ~ rnorm(n, 0.3, 0.1) [tl = 0.15 ; tu = 1 ] #> n_effect Min. 1st Qu. Median Mean 3rd Qu. Max. #> 1000 0.15 0.249 0.308 0.312 0.371 0.624 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> pearson 25 NULL two_sided 0.05 23 #> #> Inferential risks: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> power 0.102 0.22575 0.329 0.355294 0.46375 0.936 #> typeM 1.025 1.39900 1.627 1.743234 1.97925 3.225 #> typeS 0.000 0.00000 0.000 0.004147 0.00400 0.071 #> #> Critical value(s): rho = ± 0.396
retrospective(effect_size = function(n) rnorm(n, .3, .1), sample_n1 = 25, test_method = "one_sample", tl = .2, tu = .4, B = 1e3)
#> Truncation could require long computational time
#> #> Design Analysis #> #> Hypothesized effect: cohen_d ~ rnorm(n, 0.3, 0.1) [tl = 0.2 ; tu = 0.4 ] #> n_effect Min. 1st Qu. Median Mean 3rd Qu. Max. #> 1000 0.2 0.258 0.299 0.3 0.342 0.4 #> #> Study characteristics: #> test_method sample_n1 sample_n2 alternative sig_level df #> one_sample 25 NULL two_sided 0.05 24 #> #> Inferential risks: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> power 0.146 0.236 0.300 0.308001 0.37600 0.516 #> typeM 1.454 1.673 1.866 1.917553 2.11825 2.690 #> typeS 0.000 0.000 0.000 0.002266 0.00400 0.026 #> #> Critical value(s): cohen_d = ± 0.413
# }